mercredi 28 février 2018

In laravel 5.4 how can i get only the users friends posts?

$user_id = auth::user()->id;
$user_friends = User::find($user_id)->friends;
$user_friends_id = $user_friends->pluck('id');
$posts = Post::where('user_id', $user_friends_id)->get();
return view('dashboard')->with('posts', $posts);

So far i've got the users friends id's in $user_friends_id and then matching them to the user id on the posts but its only getting the first friends posts and not the rest. How can i change it to get all the friends posts and not just the first friends?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FDJcJI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire