Fetch posts of logged in user and people he is following orderby date

Posted 3 years ago by bootstrapguru

Hello everyone, In short , I am trying to show the posts of user and his followers ordering by latest date. Exactly like Facebook feed.

I have User model with followers and posts methods as follows

    public function followers()
        return $this->belongsToMany('App\User','followers','leader_id','follower_id');
   public function posts()
      return $this->hasMany('App\Post');

also I have Post model

now I am trying to fetch posts of logged in user and his followers, I tried many ways but couldn't crack it, please help me with this. Thanks in advance for the community with great people

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.