/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Carro::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(['car_num_ejes' => $this->car_num_ejes, 'car_fecha_compra' => $this->car_fecha_compra, 'car_valor_compra' => $this->car_valor_compra]); $query->andFilterWhere(['like', 'car_patente', $this->car_patente])->andFilterWhere(['like', 'emp_rut', $this->emp_rut])->andFilterWhere(['like', 'car_marca', $this->car_marca])->andFilterWhere(['like', 'car_tipo', $this->car_tipo])->andFilterWhere(['like', 'car_observacion', $this->car_observacion])->andFilterWhere(['like', 'car_imagen', $this->car_imagen]); return $dataProvider; }
/** * Finds the Carro model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Carro the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Carro::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCarros() { return $this->hasMany(Carro::className(), ['emp_rut' => 'emp_rut']); }
/** * @return \yii\db\ActiveQuery */ public function getCarPatentes() { return $this->hasMany(Carro::className(), ['car_patente' => 'car_patente'])->viaTable('uni_veh_car', ['veh_patente' => 'veh_patente']); }