public function search($params) { $query = Staff::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['staff_id' => $this->staff_id, 'address_id' => $this->address_id, 'store_id' => $this->store_id, 'active' => $this->active, 'last_update' => $this->last_update]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'picture', $this->picture])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = StaffModel::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(['staff_id' => $this->staff_id, 'address_id' => $this->address_id, 'store_id' => $this->store_id, 'active' => $this->active, 'last_update' => $this->last_update]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'picture', $this->picture])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getStaff() { return $this->hasOne(\app\modules\sakila\models\Staff::className(), ['staff_id' => 'staff_id']); }
/** * @return \yii\db\ActiveQuery */ public function getStaff() { return $this->hasMany(\app\modules\sakila\models\Staff::className(), ['address_id' => 'address_id']); }
/** * Finds the Staff model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $staff_id * @return Staff the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($staff_id) { if (($model = Staff::findOne($staff_id)) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }