我需要获得基于belongsToMany关系的所有记录的计数。通常,我可以在模型内部的函数中使用groupBy()。FatalThrowableError: Call to a member function addEagerConstraints() on int in file /Users/dragonar/Dev/iyw/vendor/laravel
考虑到以下belongsToMany关系:class Tag extends Model public function posts (){{ return $this->belongsToMany('App\Tag');}
在laravel中,什么是最有效和可扩展的方式来查询每个标签的计数,以及根据标签计数