Sushiarkt
7 months ago
671
6
Laravel

Laravel record doesn't return It's children

Posted 7 months ago by Sushiarkt

Hi, I have a problem.

When I call a record I don't get back relations/children at all

Post::find($id)  

returns

App\Post{
	id: ...,
	title: ...,
}

and I want it to return

App\Post{
	id: ...,
	title: ...,
	photos: 
		all: [
			App\Photo {
				id: ...,
				name: ...,
			}
		]
}

But this works:

Post::find($id)->photos

So I have no idea if I messed something up while writing the relationships, but I don't think so...

I'm using Laravel 7.

Thanks!

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