How do I see the posts only from the users that I follow?

0

Model: User

public function posts(){
    return $this->hasMany(\App\Post::class);
}

public function follows() { //seguidos, a que usuarios sigue este usuario
    return $this->belongsToMany(User::class, 'followers', 'user_id', 'followed_id');
}

Model: Post

public function user(){
    return $this->belongsTo(User::class);
}

With this: \Auth::user()->follows gives me all the users that I follow, but as I do now see the posts of those users that I follow, as ago for me to load also the relationship of the posts that I already have in the model.

Thanks in advance.

    
asked by Support Google 10.10.2018 в 00:18
source

0 answers