Here is my relation:
public function commentsCount(){
return $this->belongsToMany('App\Comment','project_comment');
}
I am trying to get acount of all comments...
Here is my query
$count = Project::with(['commentsCount' => function($q) {
$q->where('project_id', $this->id);
}, 'groups' => function($q) {
$q->where('project_id', $this->id)->where('user_id', Auth::id());
}])->where('id', $this->id)->get();
Any solution?