/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Exame::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(['idexame' => $this->idexame, 'inicio' => $this->inicio, 'termino' => $this->termino]); $query->andFilterWhere(['like', 'nome', $this->nome]); return $dataProvider; }
public function actionFiltro($tipo) { $provaModel = new ProvaSearch(); $provaProvider = $provaModel->search(Yii::$app->request->queryParams); $ditems = ArrayHelper::map(Disciplina::find()->all(), 'nome', 'nome'); $citems = ArrayHelper::map(Curso::find()->all(), 'idcurso', 'nome'); $pitems = ArrayHelper::map(Predio::find()->where(['unidade' => '1'])->all(), 'idpredio', 'nome'); $sitems = ArrayHelper::map(Sala::find()->all(), 'idsala', 'nome'); $eitems = ArrayHelper::map(Exame::find()->all(), 'idexame', 'nome'); if ($provaModel->load(Yii::$app->request->get())) { return $this->render('frequencia', ['dataProvider' => $provaProvider, 'searchModel' => $provaModel]); } else { return $this->render('filtro', ['provaModel' => $provaModel, 'provaProvider' => $provaProvider, 'ditems' => $ditems, 'citems' => $citems, 'pitems' => $pitems, 'sitems' => $sitems, 'eitems' => $eitems, 'tipo' => $tipo]); } }