|
@@ -9,29 +9,37 @@ use yii\db\Expression;
|
|
|
class VehiculoController extends AuthController {
|
|
|
|
|
|
public $modelClass = "v1\models\Vehiculo";
|
|
|
-
|
|
|
public function actionIndex() {
|
|
|
$id = trim($this->req->get("id", ""));
|
|
|
$buscar = trim($this->req->get("q", ""));
|
|
|
+ $tipo = trim($this->req->get("tipo", ""));
|
|
|
+ $marca = trim($this->req->get("marca", ""));
|
|
|
|
|
|
$query = $this->queryInicial;
|
|
|
|
|
|
- if($id !== "" ) {
|
|
|
- $query->andWhere(["id" => $id]);
|
|
|
+ if ($id !== "") {
|
|
|
+ $query->andWhere(["id" => $id]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($buscar) {
|
|
|
+ // Ejemplo de buscador
|
|
|
+ $query->andWhere([
|
|
|
+ "OR",
|
|
|
+ ["ilike", "nombre", $buscar]
|
|
|
+ ]);
|
|
|
+ //
|
|
|
}
|
|
|
|
|
|
- if($buscar) {
|
|
|
- # Ejemplo de buscador
|
|
|
-
|
|
|
- $query->andWhere([
|
|
|
- "OR",
|
|
|
- ["ilike", "nombre", $buscar]
|
|
|
- ]);
|
|
|
- //
|
|
|
+ if ($tipo !== "") {
|
|
|
+ $query->andWhere(["tipo" => $tipo]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($marca !== "") {
|
|
|
+ $query->andWhere(["marca" => $marca]);
|
|
|
}
|
|
|
|
|
|
return new Respuesta($query, $this->limite, $this->pagina, $this->ordenar);
|
|
|
- }
|
|
|
+}
|
|
|
|
|
|
public function actionGuardar() {
|
|
|
$id = trim($this->req->getBodyParam("id", ""));
|