Going down multiple relationship layers

Posted 1 year ago by Verdemis

Hello everyone,

I have some Models with relationships....

'Pages' with many 'Boxes' 'Boxes' belongs to one 'Item'

I now want to get a page from my database with his boxes and their items.

I tried it like this

$page = Page::with('boxes', function($query){
     $query->with('item');
})->where('id',$id)->first();

But this doesn't work. Has anyone a hint for me how to do that?

Best, Verdemis

Please sign in or create an account to participate in this conversation.