Manejo de excepciones
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Venta;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement;
|
||||
@ -17,14 +19,7 @@ class Propiedad extends Ideal\Repository
|
||||
|
||||
public function create(?array $data = null): Model\Venta\Propiedad
|
||||
{
|
||||
$map = (new Implement\Repository\MapperParser())
|
||||
->register('unidad_principal', (new Implement\Repository\Mapper())
|
||||
->setProperty('unidades')
|
||||
->setDefault([])
|
||||
->setFunction(function($data) {
|
||||
return [$this->unidadService->getById($data['unidad_principal'])];
|
||||
})
|
||||
)
|
||||
$map = (new Implement\Repository\MapperParser(['unidad_principal', 'estacionamientos', 'bodegas', 'estado']))
|
||||
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
|
||||
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
|
||||
}
|
||||
@ -67,7 +62,10 @@ class Propiedad extends Ideal\Repository
|
||||
*/
|
||||
public function fetchVigenteByUnidad(int $unidad_id): Model\Venta\Propiedad
|
||||
{
|
||||
$query = "SELECT * FROM `{$this->getTable()}` WHERE `unidad_principal` = ?";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select()
|
||||
->from($this->getTable())
|
||||
->where('`unidad_principal` = ? AND `estado` = 1');
|
||||
return $this->fetchOne($query, [$unidad_id]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user