Poder editar propietario de ventas, cambiando el propietario en si

This commit is contained in:
Juan Pablo Vial
2024-07-04 15:42:10 -04:00
parent 0d5c9efd68
commit 964d8d4237
7 changed files with 546 additions and 162 deletions

View File

@ -37,20 +37,36 @@ class Comuna extends Ideal\Repository
public function fetchByDescripcion(string $descripcion): Define\Model
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `descripcion` = ?";
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('descripcion = ?');
return $this->fetchOne($query, [$descripcion]);
}
public function fetchByProvincia(int $provincia_id): array
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `provincia` = ?";
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('provincia = ?');
return $this->fetchMany($query, [$provincia_id]);
}
public function fetchByRegion(int $region_id): array
{
$query = $this->connection->getQueryBuilder()
->select('c.*')
->from("{$this->getTable()} c")
->joined('JOIN provincia p ON c.provincia = p.id')
->where('p.region = ?');
return $this->fetchMany($query, [$region_id]);
}
public function fetchByDireccion(string $direccion): array
{
$query = "SELECT a.*
FROM `{$this->getTable()}` a
JOIN `direccion` ON `direccion`.`comuna` = a.`id`
WHERE TRIM(CONCAT_WS(' ', `direccion`.`calle`, `direccion`.`numero`, `direccion`.`extra`)) LIKE ?";
$query = $this->connection->getQueryBuilder()
->select('c.*')
->from("{$this->getTable()} c")
->joined('JOIN direccion d ON c.id = d.comuna')
->where('TRIM(CONCAT_WS(" ", d.calle, d.numero, d.extra)) LIKE ?');
return $this->fetchMany($query, ["%{$direccion}%"]);
}
}

View File

@ -74,4 +74,8 @@ class Propietario extends Ideal\Repository
{
return $this->update($model, ['dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'], $new_data);
}
public function filterData(array $data): array
{
return array_intersect_key($data, array_flip(['rut', 'dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'representante']));
}
}