protected function user($username = '') { $user = User::findOne(['username' => $username]); if ($user === null) { throw new NotFoundHttpException(); } return $user; }