/** * @param $name * @return Service * @throws NotFoundHttpException */ protected function findModel($name) { if (($model = Service::findOne(['model_name' => $name])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }