我需要获得基于belongsToMany关系的所有记录的计数。通常,我可以在模型内部的函数中使用groupBy()。但是如果我在模型函数中使用count()或withCount(),我会得到如下错误: 功能代码: public function TaskCount(){
return $this->belongsToManyFatalThrowableError: Call to a member function addEagerConstraints() on int in file /Users/dr