F
F
FMars2016-06-08 22:42:30
MySQL
FMars, 2016-06-08 22:42:30

Laravel Eloquent. How to choose a relationship model?

Hello!
How can you choose a model with relationships:

$article = Article::with('author')->where('status', true)->get();

The author also has an attitude to the place of work.
$author->job->name;
How to select in one query an article with an author and his place of work?
That is something like this:
$article = Article::with('author'->with('job'))->where('status', true)->get();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2016-06-08
@FMars

$article = Article::with(['author', 'author.job'])->where('status', true)->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question