/** * Finds the Forum model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Forum the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Forum::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Forum model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Forum the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (is_numeric($id)) { $model = Forum::findOne($id); } else { $model = Forum::find()->where(['forum_url' => $id])->one(); } if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }