[Vuejs]-User Information of following users

0👍

Followers are also user, so in this case you can join the user twice by giving different name. I made a query, you can try or make it fix for your use. I guess you got the concept, if I’m missing something just let me know.

$test = Posts::select('posts.*','users.*', followers.*, follower.name as follower_name
                  ->join('followers', 'posts.user_id', '=', 'followers.follower_id')
                  ->join('users as users', 'followers.user_id', '=', 'users.id')
                  ->join('users as follower', 'followers.follower_id', '=', 'users.id')
                  ->where('users.id', $user->id)
                  ->get();

Leave a comment