/** * Counts the project's issues assigned to the given user * * @param int $user_id * @return int */ public function count_assigned_issues($user_id = null) { if (is_null($user_id)) { $user_id = \Auth::user()->id; } return \Project\Issue::where('project_id', '=', $this->id)->where('assigned_to', '=', $user_id)->where('status', '=', 1)->count(); }