/** * @param $slug * @return Terms|null * @throws NotFoundHttpException */ protected function findModel($slug) { if (($model = Terms::findOne(['slug' => $slug])) !== null) { return $model; } else { throw new NotFoundHttpException('La categorÃa no existe.'); } }