No Model found for collection ArtistList - Laravel SmartCollection

Feature(s) impacted

Creating a smart collection following the guide in Smart Collections - Developer guide

Observed behavior

On accessing the “Artist Lists” collection in the UI, errors and returns 500 error on api - No model found for collection ArtistList

I’ve also noticed the generated forest schema doesn’t have a class given for the virtual class artistList like it does the other classes - is that intended?

Expected behavior

Displays collection in UI using artistList model

Failure Logs

Can DM.

Context

  • Project name: …
  • Team name: …
  • Environment name: …
  • Agent type & version: Laravel 1.2.2
  • Recent changes made on your end if any: …

Hi @EFGP :wave:,

Could you share this model and its controller ?

For the .forestadmin-schema.json, this is normal because we don’t need the class name for a smart collection.

I think that the issue come from the route declaration.
The route was declared in api.php and by default all the routes in api.php has the prefix “api”.

Can you check if the route forest/artistList has the prefix “api” with the command php artisan route:list ?

If so, you can remove the prefix “api” in the boot() function of the RouteServiceProvider.php or declare this route in web.php.

2 Likes

Yep sorry didn’t notice that - that’s resolved it by moving the route definition into the web.php file rather than api.php so it doesn’t have the /api prefix.

I have another question about related data for SmartCollection but will open a new thread.

2 Likes