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 Credito extends Ideal\Repository
{
public function __construct(Define\Connection $connection, protected Pago $pagoRepository)
public function __construct(Define\Connection $connection, protected Service\Venta\Pago $pagoService)
{
parent::__construct($connection);
$this->setTable('credito');
@ -15,13 +17,11 @@ class Credito extends Ideal\Repository
public function create(?array $data = null): Define\Model
{
$map = [
'pago' => [
'function' => function($data) {
return $this->pagoRepository->fetchById($data['pago']);
}
]
];
$map = (new Implement\Repository\MapperParser())
->register('pago', (new Implement\Repository\Mapper())
->setFunction(function($data) {
return $this->pagoService->getById($data['pago']);
}));
return $this->parseData(new Model\Venta\Credito(), $data, $map);
}
public function save(Define\Model $model): Define\Model