Skip to content
Advertisement

Laravel 8 resource controller not fetching model

In Laravel 7 fetching a model was pretty straightforward, i just needed to setup mi resource route and make a get to the address:

http://localhost/test/public/employee/1

But i cant make it work on Laravel 8, according to my understanding i just need to do this:

JavaScript

But dd only returns an empty class:

dd result

If i do this:

JavaScript

dd returns the correct data:

dd correct

JavaScript

Can somebody help me find what am i missing?

Regards…

Advertisement

Answer

The problem was that i was naming the routes in spanish:

JavaScript

And because of this Laravel is expecting to receive the model encapsulated in a spanish verb class (empleados instead of employee), So i needed to rename the parameter inside the method controllers to receive the correct model:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement