Implemented repository mapper, and venta show
This commit is contained in:
@ -3,6 +3,7 @@ namespace Incoviba\Repository\Venta;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
@ -21,12 +22,10 @@ class Propietario extends Ideal\Repository
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'dv' => [],
|
||||
'nombres' => [],
|
||||
'apellido_paterno' => [
|
||||
'property' => 'apellidos',
|
||||
'function' => function($data) {
|
||||
$map = (new Implement\Repository\MapperParser(['dv', 'nombres']))
|
||||
->register('apellido_paterno', (new Implement\Repository\Mapper())
|
||||
->setProperty('apellidos')
|
||||
->setFunction(function($data) {
|
||||
$arr = [
|
||||
'paterno' => $data['apellido_paterno']
|
||||
];
|
||||
@ -34,35 +33,25 @@ class Propietario extends Ideal\Repository
|
||||
$arr['materno'] = $data['apellido_materno'];
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
],
|
||||
'direccion' => [
|
||||
'property' => 'datos',
|
||||
'function' => function($data) {
|
||||
}))
|
||||
->register('direccion', (new Implement\Repository\Mapper())
|
||||
->setProperty('datos')
|
||||
->setFunction(function($data) {
|
||||
$datos = new Model\Venta\Datos();
|
||||
if ($data['direccion'] !== null and $data['direccion'] !== 0) {
|
||||
$datos->direccion = $this->direccionRepository->fetchById($data['direccion']);
|
||||
}
|
||||
return $datos;
|
||||
}
|
||||
],
|
||||
'representante' => [
|
||||
'function' => function($data) {
|
||||
}))
|
||||
->register('representante', (new Implement\Repository\Mapper())
|
||||
->setFunction(function($data) {
|
||||
if ($data['representante'] === null or $data['representante'] === 0) {
|
||||
return null;
|
||||
}
|
||||
return $this->fetchById($data['representante']);
|
||||
}
|
||||
],
|
||||
'otro' => [
|
||||
'function' => function($data) {
|
||||
if ($data['otro'] === null) {
|
||||
return null;
|
||||
}
|
||||
return $data['otro'] !== 0;
|
||||
}
|
||||
]
|
||||
];
|
||||
}))
|
||||
->register('otro', (new Implement\Repository\Mapper\Boolean('otro'))
|
||||
->setDefault(null));
|
||||
return $this->parseData(new Model\Venta\Propietario(), $data, $map);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user