/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Pastoreio::find(); $query->joinWith('relIdPastor'); $query->joinWith('relIdRebanho'); $query->joinWith('relIdExploracao'); // add conditions that should always apply here $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; } // grid filtering conditions /*$query->andFilterWhere([ 'idPastor' => $this->idPastor, 'idRebanho' => $this->idRebanho, 'data' => $this->data, ]); */ $query->andFilterWhere(['like', 'Pessoa.nome', $this->idPastor])->andFilterWhere(['like', 'Rebanho.designacao', $this->idRebanho])->andFilterWhere(['like', 'Exploracao.nome', $this->idExploracao])->andFilterWhere(['like', 'data', $this->data]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getPastoreios() { return $this->hasMany(Pastoreio::className(), ['idRebanho' => 'idRebanho']); }
/** * @return \yii\db\ActiveQuery */ public function getPastoreios() { return $this->hasMany(Pastoreio::className(), ['idPastor' => 'idPessoa']); }
/** * Finds the Pastoreio model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $idPastor * @param integer $idRebanho * @param string $idExploracao * @return Pastoreio the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($idPastor, $idRebanho, $idExploracao) { if (($model = Pastoreio::findOne(['idPastor' => $idPastor, 'idRebanho' => $idRebanho, 'idExploracao' => $idExploracao])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getPastoreios() { return $this->hasMany(Pastoreio::className(), ['idExploracao' => 'marca']); }