/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Pessoa::find(); // 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(['idPessoa' => $this->idPessoa, 'idPais' => $this->idPais, 'dataNasc' => $this->dataNasc, 'idProfissao' => $this->idProfissao, 'ativo' => $this->ativo, 'padrinho' => $this->padrinho, 'nrAnimaisApadrinha' => $this->nrAnimaisApadrinha, 'dataAssociacao' => $this->dataAssociacao, 'pastor' => $this->pastor, 'dono' => $this->dono]); $query->andFilterWhere(['like', 'nome', $this->nome])->andFilterWhere(['like', 'morada', $this->morada])->andFilterWhere(['like', 'localidade', $this->localidade])->andFilterWhere(['like', 'concelho', $this->concelho])->andFilterWhere(['like', 'distrito', $this->distrito])->andFilterWhere(['like', 'codPostal', $this->codPostal])->andFilterWhere(['like', 'genero', $this->genero])->andFilterWhere(['like', 'telef', $this->telef])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'nif', $this->nif])->andFilterWhere(['like', 'nrSocio', $this->nrSocio]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getRelIdPastor() { return $this->hasOne(Pessoa::className(), ['idPessoa' => 'idPastor']); }
/** * @return \yii\db\ActiveQuery */ public function getPessoas() { return $this->hasMany(Pessoa::className(), ['idPais' => 'idPais']); }
<div class="exploracao-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'marca')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'nome')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'idDono')->dropDownList(ArrayHelper::map(Pessoa::find()->where(['dono' => 'TRUE'])->all(), 'idPessoa', 'nome'), ['prompt' => 'Escolher Dono']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Criar' : 'Atualizar', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getRelIdDono() { return $this->hasOne(Pessoa::className(), ['idPessoa' => 'idDono']); }
/** * Finds the Pessoa model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $idPessoa * @param integer $idPais * @param integer $idProfissao * @return Pessoa the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($idPessoa, $idPais, $idProfissao) { if (($model = Pessoa::findOne(['idPessoa' => $idPessoa, 'idPais' => $idPais, 'idProfissao' => $idProfissao])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getIdPessoa0() { return $this->hasOne(Pessoa::className(), ['idPessoa' => 'idPessoa']); }