/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($idevento) { $query = EventoHasVoluntario::find()->where(['evento_idevento' => $idevento]); $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(['evento_idevento' => $this->evento_idevento, 'voluntario_idvoluntario' => $this->voluntario_idvoluntario]); return $dataProvider; }
public function searchVoluntarios() { $id_evento = Yii::$app->request->post('evento_idevento'); if (!Yii::$app->user->isGuest) { //$query = ItemProgramacao::find()->where(['evento_idevento' => $id_evento]); $query = EventoHasVoluntario::find()->where(['evento_idevento' => $id_evento])->innerJoin('voluntario', 'voluntario.idvoluntario = evento_has_voluntario.voluntario_idvoluntario')->orderBy('voluntario.nome'); } else { return Yii::$app->getResponse()->redirect(array('/evento/', NULL)); // é redirecionado a tela de eventos, se não estiver logado } $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; } return $dataProvider; }