This commit is contained in:
Juan Pablo Vial
2024-03-18 13:51:57 -03:00
parent 7385225a2e
commit 7c6a397e31
8 changed files with 42 additions and 24 deletions

View File

@ -20,13 +20,9 @@ class Inmobiliaria extends Ideal\Repository
return 'rut';
}
public function create(?array $data = null): Define\Model
public function create(?array $data = null): Model\Inmobiliaria
{
$map = (new Implement\Repository\MapperParser(['dv', 'razon', 'abreviacion', 'cuenta']))
->register('banco', (new Implement\Repository\Mapper())
->setFunction(function($data) {
return $this->bancoRepository->fetchById($data['banco']);
}))
$map = (new Implement\Repository\MapperParser(['dv', 'razon', 'abreviacion']))
->register('sociedad', (new Implement\Repository\Mapper())
->setProperty('tipoSociedad')
->setFunction(function($data) {
@ -34,7 +30,7 @@ class Inmobiliaria extends Ideal\Repository
}));
return $this->parseData(new Model\Inmobiliaria(), $data, $map);
}
public function save(Define\Model $model): Define\Model
public function save(Define\Model $model): Model\Inmobiliaria
{
$model->rut = $this->saveNew(
['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
@ -42,7 +38,7 @@ class Inmobiliaria extends Ideal\Repository
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Define\Model
public function edit(Define\Model $model, array $new_data): Model\Inmobiliaria
{
return $this->update($model, ['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'], $new_data);
}