I have a loop like this in my blade.php file:
@foreach ($posts as $post)
<article class="post" data-postid="">
<p></p>
<div class="info">
Posted by on
</div>
<div class="interaction">
<a href="#" class="like"> </a> |
<a href="#" class="like"> </a> |
@if(Auth::user() == $post->user)
<a href="#" class="edit">Edit Post</a> |
<a href="">Delete</a>
@endif
</div>
</article>
<br>
@endforeach
This is my controller function:
public function getDashboard(Request $request) {
$posts = Post::orderBy('created_at', 'desc')->get();
$countlike = Like::where(['like' => '1']);
$countdislike = Like::where(['like' => '0']);
return view('dashboard')->with(['posts' => $posts])->with(['countlike' => $countlike])->with(['countdislike' => $countdislike]);
}
While the first post in the loop communicates with ORM, the rest doesn't. I cannot integrate eloquent ORM to the loop in the blade.php file, what am I doing wrong here?
via Göktuğ Aşçı