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

From what I can understand you have a One-to-Many relationship in your logic. So, One writer can have many posts. My question to you: why would you loop your variable writer if you only have one?

@foreach($blog->writer as $writer)
    <span>{{$writer->name}}</span>
@endforeach

The code above makes no sence. IF you want a Many-To-Many relationship then you have to change your logic... In that case you will have that Many Writers have written in a Post.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

janakad janakad Joined 21 Sep 2016

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.