Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Offices::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(['office_id' => $this->office_id, 'department_id' => $this->department_id, 'office_updated' => $this->office_updated, 'office_created' => $this->office_created]);
     $query->andFilterWhere(['like', 'office_name', $this->office_name])->andFilterWhere(['like', 'office_name_en', $this->office_name_en])->andFilterWhere(['like', 'office_address', $this->office_address])->andFilterWhere(['like', 'office_position', $this->office_position])->andFilterWhere(['like', 'office_tel', $this->office_tel])->andFilterWhere(['like', 'office_fax', $this->office_fax])->andFilterWhere(['like', 'office_email', $this->office_email])->andFilterWhere(['like', 'office_logo', $this->office_logo])->andFilterWhere(['like', 'office_status', $this->office_status]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Finds the Offices model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Offices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Offices::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }