Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel中的多个关系_Php_Laravel_Eloquent - Fatal编程技术网

Php Laravel中的多个关系

Php Laravel中的多个关系,php,laravel,eloquent,Php,Laravel,Eloquent,我需要在Laravel中加载多个关系,但我不知道如何实现。在Laravel文档中,它显示了如何仅为一个关系执行此操作,如: $books=Book::with('author.contacts')->get() 我需要像这样的东西: $books=Book::with(数组('author'=>array('contacts','groups','orders'))->get() 有什么想法吗?试试这个: $books = Book::with('author.contacts','author

我需要在Laravel中加载多个关系,但我不知道如何实现。在Laravel文档中,它显示了如何仅为一个关系执行此操作,如:

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

我需要像这样的东西:

$books=Book::with(数组('author'=>array('contacts','groups','orders'))->get()

有什么想法吗?

试试这个:

$books = Book::with('author.contacts','author.groups', 'author.orders')->get();

你好,马卡努。如果您具有这种关系结构,并且希望通过
合同的
id
进行排序
排序
,我们该怎么做?当使用渴望加载时。嗨@Jonjie,这个问题已经有一段时间了,我现在不能回答这个问题,所以我建议你作为一个新问题来问。