/** * Get match name * @return string */ public function getMatchName() { $matchTable = Match::tableName(); $relationTable = Relation::tableName(); $match = Match::find()->innerJoin($relationTable, "{$matchTable}.id = {$relationTable}.parent_id")->where(["{$relationTable}.relationable_type" => Relation::RELATIONABLE_ALBUM, "{$relationTable}.relationable_id" => $this->id])->one(); if (!isset($match)) { return 'Матч не найден'; } else { $date = date('d.m.Y', strtotime($match->date)); return $match->name . ' (' . $date . ')'; } return ''; }
/** * Url: /match/{$id}/videos * @param $id Match id * @return mixed * @throws NotFoundHttpException */ public function actionMatchVideos($id) { $match = Match::findOne($id); if (!isset($match)) { throw new NotFoundHttpException('The requested page does not exist.'); } $title = "Видео матча " . $match->name; $videoPostTable = VideoPost::tableName(); $relationTable = Relation::tableName(); $query = VideoPost::find()->innerJoin($relationTable, "{$videoPostTable}.id = {$relationTable}.relationable_id")->where(['is_public' => 1, "{$relationTable}.relationable_type" => Relation::RELATIONABLE_VIDEO, "{$relationTable}.parent_id" => $match->id])->orderBy(['created_at' => SORT_DESC]); $videosDataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $emptyText = 'Видеозаписей к матчу не найдено'; return $this->render('@frontend/views/site/index', ['templateType' => 'col2', 'title' => 'Dynamomania.com | ' . $title, 'columnFirst' => ['menu' => ['view' => '@frontend/views/translation/menu', 'data' => compact('match')], 'content' => ['view' => '@frontend/views/site/videos', 'data' => compact('videosDataProvider', 'emptyText')]], 'columnSecond' => ['short_news' => SiteBlock::getshortNews(50)]]); }