/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contract::find(); $contractTable = Contract::tableName(); $playerTable = Player::tableName(); $teamTable = Team::tableName(); $seasonTable = Season::tableName(); $ampluaTable = Amplua::tableName(); $query->joinWith(['player' => function ($query) use($playerTable) { $query->from(['player' => $playerTable]); }]); $query->joinWith(['team' => function ($query) use($teamTable) { $query->from(['team' => $teamTable]); }]); $query->joinWith(['teamFrom' => function ($query) use($teamTable) { $query->from(['teamFrom' => $teamTable]); }]); $query->joinWith(['season' => function ($query) use($seasonTable) { $query->from(['season' => $seasonTable]); }]); $query->joinWith(['amplua' => function ($query) use($ampluaTable) { $query->from(['amplua' => $ampluaTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $addSortAttributes = ["player.lastname", "teamFrom.name", "team.name", "season.name", "amplua.name"]; foreach ($addSortAttributes as $addSortAttribute) { $dataProvider->sort->attributes[$addSortAttribute] = ['asc' => [$addSortAttribute => SORT_ASC], 'desc' => [$addSortAttribute => SORT_DESC]]; } if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(["{$contractTable}.id" => $this->id, 'command_id' => $this->command_id, 'season_id' => $this->season_id, 'amplua_id' => $this->amplua_id, 'number' => $this->number, 'command_from_id' => $this->command_from_id, 'year_from' => $this->year_from, 'year_till' => $this->year_till, 'matches' => $this->matches, 'goals' => $this->goals, 'is_active' => $this->is_active, 'debut' => $this->debut, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'teamFrom.name', $this->getAttribute('teamFrom.name')])->andFilterWhere(['like', 'team.name', $this->getAttribute('team.name')])->andFilterWhere(['like', 'player.lastname', $this->getAttribute('player.lastname')])->andFilterWhere(['like', 'season.name', $this->getAttribute('season.name')])->andFilterWhere(['like', 'amplua.name', $this->getAttribute('amplua.name')]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Membership::find(); $membershipTable = Membership::tableName(); $teamTable = Team::tableName(); $playerTable = Player::tableName(); $ampluaTable = Amplua::tableName(); $query->joinWith(['team' => function ($query) use($teamTable) { $query->from(['team' => $teamTable]); }]); $query->joinWith(['amplua' => function ($query) use($ampluaTable) { $query->from(['amplua' => $ampluaTable]); }]); $query->joinWith(['player' => function ($query) use($playerTable) { $query->from(['player' => $playerTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]); // enable sorting for the related columns $addSortAttributes = ["team.name", "amplua.name", "player.name"]; foreach ($addSortAttributes as $addSortAttribute) { $dataProvider->sort->attributes[$addSortAttribute] = ['asc' => [$addSortAttribute => SORT_ASC], 'desc' => [$addSortAttribute => SORT_DESC]]; } if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(["{$membershipTable}.id" => $this->id, 'command_id' => $this->command_id, 'player_id' => $this->player_id, 'number' => $this->number, 'amplua_id' => $this->amplua_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'team.name', $this->getAttribute('team.name')]); $query->andFilterWhere(['like', 'player.lastname', $this->getAttribute('player.name')]); $query->andFilterWhere(['like', 'amplua.name', $this->getAttribute('amplua.name')]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Amplua::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'line' => $this->line]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'abr', $this->abr]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Player::find(); $playerTable = Player::tableName(); // set up query with relation to `user.username` $ampluaTable = Amplua::tableName(); $query->joinWith(['amplua' => function ($query) use($ampluaTable) { $query->from(['amplua' => $ampluaTable]); }]); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); // enable sorting for the related columns $addSortAttributes = ["amplua.name"]; foreach ($addSortAttributes as $addSortAttribute) { $dataProvider->sort->attributes[$addSortAttribute] = ['asc' => [$addSortAttribute => SORT_ASC], 'desc' => [$addSortAttribute => SORT_DESC]]; } if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(["{$playerTable}.id" => $this->id, 'birthday' => $this->birthday, 'height' => $this->height, 'weight' => $this->weight, 'amplua_id' => $this->amplua_id, 'country_id' => $this->country_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'more_ampluas', $this->more_ampluas])->andFilterWhere(['like', 'amplua.name', $this->getAttribute('amplua.name')]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getAmplua() { return $this->hasOne(Amplua::className(), ['id' => 'amplua_id']); }
/** * Finds the Amplua model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Amplua the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Amplua::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use dosamigos\selectize\SelectizeDropDownList; use yii\helpers\Url; use kartik\select2\Select2; use yii\helpers\ArrayHelper; use common\models\Amplua; /* @var $this yii\web\View */ /* @var $model common\models\Composition */ $this->title = 'Добавить игрока в состав'; $this->params['breadcrumbs'][] = ['label' => 'Составы команд матчей', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="composition-create"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php $form = ActiveForm::begin(['id' => 'team' . $model->command_id . '-player-add-form']); echo $form->field($contractModel, 'player_id')->widget(SelectizeDropDownList::classname(), ['loadUrl' => Url::to(['player/player-list']), 'options' => ['multiple' => false], 'clientOptions' => ['valueField' => 'value', 'labelField' => 'text', 'persist' => false]]); echo $form->field($contractModel, 'amplua_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Amplua::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите амплуа...'], 'pluginOptions' => ['allowClear' => true]]); echo $form->field($contractModel, 'number')->textInput(); echo $form->field($model, 'is_basis')->widget(CheckboxX::classname(), ['pluginOptions' => ['threeState' => false], 'options' => ['id' => 'team' . $model->command_id . '-create-is_basis']]); echo $form->field($model, 'is_captain')->widget(CheckboxX::classname(), ['pluginOptions' => ['threeState' => false], 'options' => ['id' => 'team' . $model->command_id . '-create-is_captain']]); echo Html::submitButton('Добавить', ['class' => 'btn btn-primary']); ActiveForm::end(); ?> </div>