Answer the question
In order to leave comments, you need to log in
If the data on the Laravel page is derived from many tables, is it customary to make many models and shove them into one controller?
Hello.
I decided to remake the input form of one project based on Laravel (-:
The essence of the question is this:
- The form has a bunch of drop-down lists and the customer wants them to be formed from the database (so that he can directly influence the content of the form by managing the database).
Accordingly, under each list - you need a table.
And for each table - a Laravel model.
And how to display it later? In one controller, access all these models or what?
How is it customary to do this in Laravel?
Thank you.
Answer the question
In order to leave comments, you need to log in
Each table has its own model.
For example Auto to the autos table
In the controller at the very top use App\Models\Auto;
And all the necessary models.
In the controller method itself $autos = Auto::all();
And so for all the necessary models in the form
And we pass the variables to the blade template
And there, through foreach, we sort through the lists
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question