0
嗨,我是Laravel新手,目前正在使用Laravel 5.2。我正在尝试创建一个应用程序,其中有帖子和评论,评论有答复表并具有以下模型。laravel一对多对多关系
Post模型
public function comments() {
return $this->hasMany('App\Comment');
}
评价模型
public function posts() {
return $this->belongsTo('App\Post');
}
public function replies() {
return $this->hasMany('App\Reply');
}
回复型号
public function comments() {
return $this->belongsTo('App\Comment');
}
我想交流什么hieve:
帖子与回复,请发表评论
后 - >许多意见 - >许多回复
我能够用以下
$posts = Post::with('comments')->get();
获得评论,但不知道如何获得回复评论