as title says I want to make a loop foreach item where the post_user_id and user_id match, but just dont know quite how
@foreach($posts as $post where $post->user_id == auth()->user()->id)
@endforeach
There many posts with different post_user_id’s but i want for a specific account to see all his own posts.
2
Answers
It receives all the data where the
user_id
andpost->user_id
matches and everything works.You are not supposed to do this logic in your blade file. Rather you should do it in your controller and just pass the variable to the view/blade file.
For example. In your controller:
Now in your view file you can just loop over this variable as normal: