-1

I tried to use withCount() method just like the documentation and always i get this error : Call to undefined method 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;


}

any suggestion ?

Mahmoud Abd AL Kareem
  • 615
  • 2
  • 10
  • 23

1 Answers1

0

I solved the issue by updating the composer. composer update

Mahmoud Abd AL Kareem
  • 615
  • 2
  • 10
  • 23