/** * Finds the Coach model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Coach the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Coach::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Url: /coach/{$id}-{$slug} * @param int $id Player id * @param $slug * @return mixed * @throws NotFoundHttpException */ public function actionCoach($id, $slug) { $coach = Coach::findOne($id); if (!isset($coach)) { throw new NotFoundHttpException('Страница не найдена.'); } $image = $coach->getAsset(Asset::THUMBNAIL_CONTENT); $options = ['templateType' => 'col2', 'title' => 'Dynamomania.com | ' . $coach->name, 'columnFirst' => ['post' => ['view' => '@frontend/views/site/coach', 'data' => compact('coach', 'image'), 'weight' => 0]], 'columnSecond' => ['blog_column' => SiteBlock::getBlogPosts(), 'banner1' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner2' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner3' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner4' => SiteBlock::getBanner(Banner::REGION_NEWS), 'banner5' => SiteBlock::getBanner(Banner::REGION_NEWS)]]; return $this->render('@frontend/views/site/index', $options); }