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();
獲得評論,但不知道如何獲得回覆評論