/**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = DepartmentsModel::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(['like', 'dept_no', $this->dept_no])->andFilterWhere(['like', 'dept_name', $this->dept_name]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDeptNo()
 {
     return $this->hasOne(\giiant\sakila\models\Departments::className(), ['dept_no' => 'dept_no']);
 }
 /**
  * Finds the Departments model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $dept_no
  * @return Departments the loaded model
  * @throws HttpException if the model cannot be found
  */
 protected function findModel($dept_no)
 {
     if (($model = Departments::findOne($dept_no)) !== null) {
         return $model;
     } else {
         throw new HttpException(404, 'The requested page does not exist.');
     }
 }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDeptNos0()
 {
     return $this->hasMany(\giiant\sakila\models\Departments::className(), ['dept_no' => 'dept_no'])->viaTable('dept_manager', ['emp_no' => 'emp_no']);
 }