我在用户和类别之间有多对多的关系。在第三张表中,我有一个名为category_id的字段来引用每个记录所属的类别。我设置了一个系统,一旦用户登录,我希望他们查看具有他们在注册时选择的类别的category_id的记录。 我的代码如下所示 我在用户模型这种关系设置, public function categories()
{
return $this->belongsToMany('A
所以我有一个部分,人们可以发表评论,并给予这些意见。 我想基于有多少喜欢来组织评论。 所以我用这样的 $art = Article::with('category')
->with(array('comments' => function($comments){
//i get the comments related to the article and the count of l