How to pass a value from a method in the model?

Good afternoon. I pass to the method some value say "$slug"
And when you call the model, in conjunction of this model with another model, I need to specify where the $slug


Help how can I do that? If there is an alternative approach that will also work
March 12th 20 at 08:39
1 answer
March 12th 20 at 08:41
There is a very alternative approach. You could even say, secret. Called reading documentation.

Sometimes you may wish to eager load a relationship, but also specify additional query constraints for the eager loading query. Here's an example:

$users = App\User::with(['posts' => function ($query) {
 $query->where('title', 'like', '%first%');
Very spicy!)))
You could even say, secret. Called reading the documentation.

Just need to know what to look for))
Thank you very much!) - Thora_Orn commented on March 12th 20 at 08:44
To know what to look for, once is enough to read it from cover to cover. - tom commented on March 12th 20 at 08:47
@Thora_Orn, join the speaker above — Doku you have to read all of it, not trying to understand and remember — in the head "will develop a" table of contents, and then the next time you think of that "uh, Doc, what was that" and will have to look for the subject. Otherwise, it will remain a photo gallery from the toaster. - Lace commented on March 12th 20 at 08:50

Find more questions by tags Laravel