/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = PeriodosAfastamento::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(['id_periodo_afastamento' => $this->id_periodo_afastamento, 'id_usuario' => $this->id_usuario, 'id_tipo_afastamento' => $this->id_tipo_afastamento, 'data_inicio' => $this->data_inicio, 'data_fim' => $this->data_fim, 'criado_por' => $this->criado_por, 'criado_em' => $this->criado_em, 'modificado_por' => $this->modificado_por, 'modificado_em' => $this->modificado_em, 'ativo' => 1]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPeriodosAfastamentos() { return $this->hasMany(PeriodosAfastamento::className(), ['tipo_afastamento' => 'id_tipo_afastamento']); }
/** * Finds the PeriodosAfastamento model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return PeriodosAfastamento the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = PeriodosAfastamento::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }