所以我有一個部分,人們可以發表評論,並給予這些意見。 我想基於有多少喜歡來組織評論。 所以我用這樣的 $art = Article::with('category')
->with(array('comments' => function($comments){
//i get the comments related to the article and the count of l
我在用戶和類別之間有多對多的關係。在第三張表中,我有一個名爲category_id的字段來引用每個記錄所屬的類別。我設置了一個系統,一旦用戶登錄,我希望他們查看具有他們在註冊時選擇的類別的category_id的記錄。 我的代碼如下所示 我在用戶模型這種關係設置, public function categories()
{
return $this->belongsToMany('A