In this section, I read about Nested Eager Loading,
but this case is not indicated there.
Can i instead
$books = App\Book::with(['author.posts', 'author.comments', 'author.rating'])->get();
do this way?
$books = App\Book::with(['author' => function ($query) {
$query->with(['posts', 'comments', 'rating'])
}])->get();
Can I make such a request?
$books = App\Book::with(['author' => function ($query) {
$query->with([
'posts' => function ($query) {
$query->with('author');
},
'comments' => function ($query) {
$query->with(['author' => function ($query) {
$query->where('created_at', '>=', now()->subDays(5));
}]);
}
]);
}])->get();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire