/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Abastecimento::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(['id' => $this->id, 'preco_litro' => $this->preco_litro, 'id_posto' => $this->id_posto, 'id_veiculo' => $this->id_veiculo, 'km' => $this->km, 'data_lancamento' => $this->data_lancamento, 'data_abastecimento' => $this->data_abastecimento]); $query->andFilterWhere(['like', 'id_motorista', $this->id_motorista]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getAbastecimento() { return $this->hasMany(Abastecimento::className(), ['id_motorista' => 'cnh']); }
/** * Finds the Abastecimento model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Abastecimento the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Abastecimento::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getAbastecimentos() { return $this->hasMany(Abastecimento::className(), ['id_veiculo' => 'renavam']); }
/** * @return \yii\db\ActiveQuery */ public function getAbastecimentos() { return $this->hasMany(Abastecimento::className(), ['id_posto' => 'id']); }