They're only loaded into memory when you actually call for them in your controller.
So, having lots of models doesn't have any performance impact.
Hi trololosha4real, you could use the Dependency Injection principle for inject the Model Dependencies into your Controller, but better than this, you could use the following roadmap:
1.- Define your Model > 2.- Define one Repository that use the Model defined > 3.- Inject the Repository in the Controller Constructor.
Then you don't need to know how the model works with the Database, and the Repository is a bridge between the Model and the Controller that allow you to disconnect the data layer from your controller, because of you could use a Database to get the data or another method to get it.
Later if you need you could use the IoC container to invert the dependency in a application central way.
Hope it helps you.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community