I'm trying to return every posts with each one's author, and also every post's comments with it's author. this is what i did:
The controller:
$posts = Post::with('comments', 'user')->latest()->paginate(3);
The Post model:
public function comments() {
return $this->hasMany('App\Comment');
}
public function user() {
return $this->belongsTo('App\User');
}
The Comment model:
public function users() {
return $this->hasOne('App\User');
}
This returns every post with their authors and the comments but not the comment's author.
what else should i do??