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();
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2xW66sp
via IFTTT
Aucun commentaire:
Enregistrer un commentaire