/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Patrol::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPatrol() { return $this->hasOne(Patrol::className(), ['id' => 'patrolid']); }
/* @var $model app\models\Scout */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="scout-form"> <?php $form = ActiveForm::begin(); ?> <?php echo Html::hiddenInput('where', $where); ?> <?php echo $form->field($model, 'patrolid')->dropDownList(ArrayHelper::map(Patrol::find()->all(), 'id', 'name'), ['prompt' => 'Choose a Patrol'])->label('Patrol'); ?> <?php echo $form->field($model, 'name')->textInput(); ?> <?php echo $form->field($model, 'phone')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * Finds the Patrol model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Patrol the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Patrol::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }