protected function findModelByCode($code) { if (($model = Registration::getByCode($code)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }