Limpieza de input de valor y filtro de datos a nivel Repo

This commit is contained in:
Juan Pablo Vial
2024-07-03 15:13:13 -04:00
parent d5b9be0196
commit d68eba5697
28 changed files with 436 additions and 189 deletions

View File

@ -39,40 +39,6 @@ class Unidad extends Ideal\Repository
{
return $this->update($model, ['subtipo', 'piso', 'descripcion', 'orientacion', 'pt'], $new_data);
}
public function editProrrateo(Model\Venta\Unidad $model, array $new_data): Model\Venta\Unidad
{
try {
$query = $this->connection->getQueryBuilder()
->select('prorrateo')
->from('unidad_prorrateo')
->where('unidad_id = ?');
$result = $this->connection->execute($query, [$model->id])->fetch(PDO::FETCH_ASSOC);
if ($result === false) {
throw new Implement\Exception\EmptyResult($query);
}
if ($new_data['prorrateo'] !== $result['prorrateo']) {
$query = $this->connection->getQueryBuilder()
->update('unidad_prorrateo')
->set('prorrateo = ?')
->where('unidad_id = ?');
$this->connection->execute($query, [$new_data['prorrateo'], $model->id]);
$model->prorrateo = $new_data['prorrateo'];
}
} catch (PDOException | Implement\Exception\EmptyResult) {
$query = $this->connection->getQueryBuilder()
->insert()
->into('unidad_prorrateo')
->columns(['unidad_id', 'prorrateo'])
->values(['?', '?']);
try {
$this->connection->execute($query, [$model->id, $new_data['prorrateo']]);
$model->prorrateo = $new_data['prorrateo'];
} catch (PDOException) {
throw new Implement\Exception\EmptyResult($query);
}
}
return $model;
}
public function fetchById(int $id): Model\Venta\Unidad
{