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