getLoginUser(); $noticeCount = $this->getNoticeCount($user->id); return ['notice_count' => $noticeCount]; } protected function getNoticeCount($userId) { $userRepo = new UserRepo(); return $userRepo->countUnreadNotifications($userId); } }