/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Entregador::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(['like', 'nome', $this->nome])->andFilterWhere(['like', 'tercei_nome', $this->tercei_nome])->andFilterWhere(['like', 'cpf', $this->cpf])->andFilterWhere(['like', 'rg', $this->rg])->andFilterWhere(['like', 'celular', $this->celular]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getEntregadors() { return $this->hasMany(Entregador::className(), ['tercei_nome' => 'nome']); }
/** * Finds the Entregador model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Entregador the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Entregador::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use app\models\Situacao; use app\models\Entregador; use app\models\Cliente; use yii\helpers\ArrayHelper; /* @var $this yii\web\View */ /* @var $model app\models\Pedido */ /* @var $form yii\widgets\ActiveForm */ $stats = ArrayHelper::getColumn(Situacao::find()->all(), function ($element) { return $element['status']; }); $statuses = array_combine($stats, $stats); $entregadores = ArrayHelper::getColumn(Entregador::find()->all(), function ($element) { return $element['nome']; }); $entregadores = array_combine($entregadores, $entregadores); $clientes = ArrayHelper::getColumn(Cliente::find()->all(), function ($element) { return $element['nome']; }); $clientes = array_combine($clientes, $clientes); $tels = ArrayHelper::getColumn(Cliente::find()->all(), function ($element) { return $element['tel']; }); $tels = array_combine($tels, $tels); ?> <div class="pedido-form">
/** * @return \yii\db\ActiveQuery */ public function getEntregador0() { return $this->hasOne(Entregador::className(), ['nome' => 'entregador']); }