Implemented repository mapper, and venta show
This commit is contained in:
@ -2,10 +2,11 @@
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal\Repository;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Direccion extends Repository
|
||||
class Direccion extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Comuna $comunaRepository)
|
||||
{
|
||||
@ -15,16 +16,10 @@ class Direccion extends Repository
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'calle' => [],
|
||||
'numero' => [],
|
||||
'extra' => [],
|
||||
'comuna' => [
|
||||
'function' => function($data) {
|
||||
return $this->comunaRepository->fetchById($data['comuna']);
|
||||
}
|
||||
]
|
||||
];
|
||||
$map = (new Implement\Repository\MapperParser(['calle', 'numero', 'extra']))
|
||||
->register('comuna', (new Implement\Repository\Mapper())->setFunction(function($data) {
|
||||
return $this->comunaRepository->fetchById($data['comuna']);
|
||||
}));
|
||||
return $this->parseData(new Model\Direccion(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
|
Reference in New Issue
Block a user