Implemented repository mapper, and venta show

This commit is contained in:
Juan Pablo Vial
2023-08-08 23:53:49 -04:00
parent ef30ae67d2
commit 59825259b6
111 changed files with 2766 additions and 612 deletions

View File

@ -3,11 +3,13 @@ namespace Incoviba\Repository\Venta;
use Incoviba\Common\Ideal;
use Incoviba\Common\Define;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Service;
class Propiedad extends Ideal\Repository
{
public function __construct(Define\Connection $connection, protected Unidad $unidadRepository)
public function __construct(Define\Connection $connection, protected Service\Venta\Unidad $unidadService)
{
parent::__construct($connection);
$this->setTable('propiedad');
@ -15,19 +17,13 @@ class Propiedad extends Ideal\Repository
public function create(?array $data = null): Define\Model
{
$map = [
'unidad_principal' => [
'property' => 'unidades',
'function' => function($data) {
return $this->unidadRepository->fetchByPropiedad($data['id']);
}
],
'estado' => [
'function' => function($data) {
return true;
}
]
];
$map = (new Implement\Repository\MapperParser())
->register('unidad_principal', (new Implement\Repository\Mapper())
->setProperty('unidades')
->setFunction(function($data) {
return $this->unidadService->getByPropiedad($data['id']);
}))
->register('estado', new Implement\Repository\Mapper\Boolean('estado'));
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
}
public function save(Define\Model $model): Define\Model