/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = SalariesModel::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(['emp_no' => $this->emp_no, 'salary' => $this->salary, 'from_date' => $this->from_date, 'to_date' => $this->to_date]); return $dataProvider; }
/** * Finds the Salaries model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $emp_no * @param string $from_date * @return Salaries the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($emp_no, $from_date) { if (($model = Salaries::findOne(['emp_no' => $emp_no, 'from_date' => $from_date])) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getSalaries() { return $this->hasMany(\giiant\sakila\models\Salaries::className(), ['emp_no' => 'emp_no']); }