Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Hi,

have you tried eager loading the posts and their statuses?

$user = User::with('posts.status')->find(17);
foreach($user->posts as $up){
     echo $up->status->name;
}
Last updated 2 years ago.
0

wow very simple, thanks flammel, it works

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.