/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = InscricaoProvaSala::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith(['prova', 'sala', 'inscricao']); $dataProvider->sort->attributes['sala'] = ['asc' => ['sala.nome' => SORT_ASC], 'desc' => ['sala.nome' => SORT_DESC]]; $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(['inscricao_idinscricao' => $this->inscricao_idinscricao, 'prova_idprova' => $this->prova_idprova, 'sala_idsala' => $this->sala_idsala, 'nota' => $this->nota])->andFilterWhere(['like', 'sala.nome', $this->nomesala]); return $dataProvider; }
/** * Finds the InscricaoHasProva model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $inscricao_idinscricao * @param integer $prova_idprova * @return InscricaoHasProva the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($inscricao_idinscricao, $prova_idprova) { if (($model = InscricaoProvaSala::findOne(['inscricao_idinscricao' => $inscricao_idinscricao, 'prova_idprova' => $prova_idprova])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getInscricaoProvaSalas() { return $this->hasMany(InscricaoProvaSala::className(), ['prova_idprova' => 'idprova']); }