Laravel Eloquent: eager loading of multiple nested relationships

前端 未结 2 1396
心在旅途
心在旅途 2020-12-13 01:27

What laravel says:

$books = App\\Book::with(\'author.contacts\')->get();

What I need is something like this

$books = App         


        
2条回答
  •  遥遥无期
    2020-12-13 02:19

    You can do

     $books = App\Book::with('author.contacts','author.publishers')->get();
    

提交回复
热议问题