Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Hello, In order to use your Model class in controller you need to add a namespace: use App\Post; - or something like that ( depends on your structure ) :)

0

Ok so, I have to know that.

If I want to use a class in a controller I must include it: "use App\MyModel" that is better than creating an allias and populating your config\app.php file, right?

0

Alias should be only created for specific classes/models. If you will add all models to alias - you will face loading problems. I have about 70 models created in total and if I will add all of them to my app.php - i will lose performance :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.