Answer the question
In order to leave comments, you need to log in
How to control automatic model loading in laravel controller method?
Using the artisan command, I created a controller bound to the Announcement model. In the same place I found a very interesting code of the following type.
public function show(Announcement $announcement)
{
/****/
}
Answer the question
In order to leave comments, you need to log in
In the context of a single model, rather than a collection, load works exactly the same as with - it makes a second query to the relationship table.
So you can even not call load, but simply use a relation - Eloquent will automatically load everything. Load is needed here only if you need to control the loading of the relation: specify an additional condition or additional links.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question