/** * Finds the Term model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param integer $id * * @return Term the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findTerm($id) { if (($model = Term::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Term model based on its primary key value. * If the model is not found, it will return false. * * @param integer $id * * @return Term|bool|null|static */ protected function findTerm($id) { if (($model = Term::findOne($id)) !== null) { return $model; } else { return false; } }
/** * Finds the Post model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * * @param $term_slug * * @throws \yii\web\NotFoundHttpException * @internal param string $post_slug * * @return Term the loaded model */ protected function findModelBySlug($term_slug) { $model = Term::findOne(['term_slug' => $term_slug]); if ($model) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }