/** * Lists all MatchEvent models. * @return mixed */ public function actionIndex() { $searchModel = new MatchEventSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $matchEventTable = $searchModel::tableName(); $matchEventTypeTable = MatchEventType::tableName(); $matchEvents = MatchEventType::find()->innerJoin($matchEventTable, "{$matchEventTable}.match_event_type_id = {$matchEventTypeTable}.id")->all(); $eventFilter = ArrayHelper::map($matchEvents, 'id', 'name'); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'eventFilter' => $eventFilter]); }
/** * Updates statistics of an existing Match model. * @param integer $id * @return mixed */ public function actionEvents($id) { $model = $this->findModel($id); $matchEventModel = new MatchEvent(); $matchEventModel->match_id = $model->id; $matchEventModelSearch = new MatchEventSearch(); $params = ['MatchEventSearch' => ['match_id' => $model->id]]; $matchEventDataProvider = $matchEventModelSearch->search($params); // $totalCount = $matchEventDataProvider->getTotalCount(); // $matchEventDataProvider->pagination = ['defaultPageSize' => 60]; $matchEventDataProvider->setSort(['defaultOrder' => ['minute' => SORT_DESC, 'additional_minute' => SORT_DESC]]); $matchEvents = MatchEventType::find()->all(); $eventFilter = ArrayHelper::map($matchEvents, 'id', 'name'); $searchModel = new CompositionSearch(); // homeCompositionDataProvider $params = ['CompositionSearch' => ['match_id' => $model->id, 'command_id' => $model->command_home_id]]; $homeCompositionDataProvider = $searchModel->search($params); $homeCompositionDataProvider->setSort(['defaultOrder' => ['is_basis' => SORT_DESC, 'number' => SORT_ASC]]); // guestCompositionDataProvider $params = ['CompositionSearch' => ['match_id' => $model->id, 'command_id' => $model->command_guest_id]]; $guestCompositionDataProvider = $searchModel->search($params); $guestCompositionDataProvider->setSort(['defaultOrder' => ['is_basis' => SORT_DESC, 'number' => SORT_ASC]]); if ($matchEventModel->load(Yii::$app->request->post()) && $matchEventModel->validate()) { $matchEventModel->save(false); $this->redirect(['match/events', 'id' => $model->id]); } return $this->render('match_events', compact('model', 'matchEventModel', 'matchEventModelSearch', 'matchEventDataProvider', 'eventFilter', 'homeCompositionDataProvider', 'guestCompositionDataProvider')); }