/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Departaments::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(['departament_id' => $this->departament_id, 'branches_branch_id' => $this->branches_branch_id, 'companies_company_id' => $this->companies_company_id, 'departament_created_date' => $this->departament_created_date]); $query->andFilterWhere(['like', 'departament_name', $this->departament_name])->andFilterWhere(['like', 'departament_status', $this->departament_status]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getDepartaments() { return $this->hasMany(Departaments::className(), ['branches_branch_id' => 'branch_id']); }
/** * @return \yii\db\ActiveQuery */ public function getDepartaments() { return $this->hasMany(Departaments::className(), ['companies_company_id' => 'company_id']); }
/** * Finds the Departaments model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Departaments the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Departaments::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }