Implemented repository mapper, and venta show
This commit is contained in:
@ -4,6 +4,7 @@ namespace Incoviba\Repository\Venta;
|
||||
use DateTimeImmutable;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
@ -17,45 +18,31 @@ class Pago extends Ideal\Repository
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'valor' => [],
|
||||
'banco' => [
|
||||
'function' => function($data) {
|
||||
$map = (new Implement\Repository\MapperParser(['valor', 'identificador', 'uf', 'pagador']))
|
||||
->register('banco', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
if ($data['banco'] === null or $data['banco'] === 0) {
|
||||
return null;
|
||||
}
|
||||
return $this->bancoRepository->fetchById($data['banco']);
|
||||
}
|
||||
],
|
||||
'tipo' => [
|
||||
'property' => 'tipoPago',
|
||||
'function' => function($data) {
|
||||
}))
|
||||
->register('tipo', (new Implement\Repository\Mapper())
|
||||
->setProperty('tipoPago')
|
||||
->setFunction(function($data) {
|
||||
if ($data['tipo'] === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->tipoPagoRepository->fetchById($data['tipo']);
|
||||
}
|
||||
],
|
||||
'identificador' => [],
|
||||
'fecha' => [
|
||||
'function' => function($data) {
|
||||
if ($data['fecha'] === null) {
|
||||
return null;
|
||||
}
|
||||
return new DateTimeImmutable($data['fecha']);
|
||||
}
|
||||
],
|
||||
'uf' => [],
|
||||
'pagador' => [],
|
||||
'asociado' => [
|
||||
'function' => function($data) {
|
||||
}))
|
||||
->register('fecha', (new Implement\Repository\Mapper\DateTime('fecha'))
|
||||
->setDefault(null))
|
||||
->register('asociado', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
if ($data['asociado'] === null) {
|
||||
return null;
|
||||
}
|
||||
return $this->fetchById($data['asociado']);
|
||||
}
|
||||
]
|
||||
];
|
||||
}));
|
||||
return $this->parseData(new Model\Venta\Pago(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
|
Reference in New Issue
Block a user