Laravel5.2 withCount 不工作
Laravel5.2 withCount not working
我尝试像文档中那样使用 withCount() 方法,但总是出现此错误:
调用未定义的方法 Illuminate\Database\Query\Builder::withCount()
public function index($id)
{
$data = \App\Institute::find($id);
if(!$data)
return response()->json(['message' => trans('system.notFound')])->setStatusCode(404);
$users = \App\MainArea::withCount('institute')->where('institute_id',$id)->get();
return $users;
}
有什么建议吗?
我通过更新作曲家解决了这个问题。
作曲家更新
我尝试像文档中那样使用 withCount() 方法,但总是出现此错误: 调用未定义的方法 Illuminate\Database\Query\Builder::withCount()
public function index($id)
{
$data = \App\Institute::find($id);
if(!$data)
return response()->json(['message' => trans('system.notFound')])->setStatusCode(404);
$users = \App\MainArea::withCount('institute')->where('institute_id',$id)->get();
return $users;
}
有什么建议吗?
我通过更新作曲家解决了这个问题。 作曲家更新