/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Oblasti::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'use_for_report' => $this->use_for_report, 'id_inspekcii' => $this->id_inspekcii]); $query->andFilterWhere(['like', 'nazva', $this->nazva])->andFilterWhere(['like', 'kerivnyk', $this->kerivnyk])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'address', $this->address]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Leshoz::find(); $query->joinWith(['region']); $dataProvider = new ActiveDataProvider(['query' => $query]); // Add extended sorts for related tables $dataProvider->sort->attributes['region.nazva'] = ['asc' => [Oblasti::tableName() . '.nazva' => SORT_ASC], 'desc' => [Oblasti::tableName() . '.nazva' => SORT_DESC]]; $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'id_obl' => $this->id_obl, 'Data_dogovora' => $this->Data_dogovora, 'post_index' => $this->post_index, 'post_obl' => $this->post_obl, 'post_region' => $this->post_region]); $query->andFilterWhere(['like', 'nazva', $this->nazva])->andFilterWhere(['like', 'N_dogovora', $this->N_dogovora])->andFilterWhere(['like', 'kerivnyk', $this->kerivnyk])->andFilterWhere(['like', 'post_town', $this->post_town])->andFilterWhere(['like', 'post_address', $this->post_address])->andFilterWhere(['like', 'email', $this->email]); // ->andFilterWhere(['like', 'region.nazva', $this->region]); return $dataProvider; }
use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Oblasti; /* @var $this yii\web\View */ /* @var $model app\models\Leshoz */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="leshoz-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'id_obl')->dropDownList(ArrayHelper::map(Oblasti::find()->all(), 'id', 'nazva'))->label(Yii::t('region', 'Nazva')); ?> <?php echo $form->field($model, 'nazva')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'N_dogovora')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'Data_dogovora')->textInput(); ?> <?php
/** * Finds the Oblasti model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Oblasti the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Oblasti::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Company-to-Region relation (head company) */ public function getRegion() { return $this->hasOne(Oblasti::className(), ['id' => 'id_obl']); }