Thanks Altim, I just hit this issue, and nested foreach is one solution. However, I will share with you guys the solution that I used at the end.
Instead of a nested foreach or even bootloader, I used Builder Builder. In my case:
$posts = DB::table('posts') ->leftJoin('users', 'posts.user_id', '=', 'users.id') ->get();
This allowed me to use one foreach, and all the data is on the same level, in my case, for example, it would be something like:
@foreach ($posts as $post) <p>{{ $post->first_name }}</p>
Perhaps he does not answer this question exactly, but I hope that he will help others, such as myself, who turned out to be in this particular question.
source share