Auth, Login, Home, Venta->Listados->Precios
This commit is contained in:
55
app/src/Repository/Inmobiliaria.php
Normal file
55
app/src/Repository/Inmobiliaria.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class Inmobiliaria extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Repository\Banco $bancoRepository, protected Repository\Inmobiliaria\TipoSociedad $tipoSociedadRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('inmobiliaria');
|
||||
}
|
||||
|
||||
protected function getKey(): string
|
||||
{
|
||||
return 'rut';
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'dv' => [],
|
||||
'razon' => [],
|
||||
'abreviacion' => [],
|
||||
'cuenta' => [],
|
||||
'banco' => [
|
||||
'function' => function($data) {
|
||||
return $this->bancoRepository->fetchById($data['banco']);
|
||||
}
|
||||
],
|
||||
'sociedad' => [
|
||||
'property' => 'tipoSociedad',
|
||||
'function' => function($data) {
|
||||
return $this->tipoSociedadRepository->fetchById($data['sociedad']);
|
||||
}
|
||||
]
|
||||
];
|
||||
return $this->parseData(new Model\Inmobiliaria(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
{
|
||||
$model->rut = $this->saveNew(
|
||||
['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
|
||||
[$model->dv, $model->razon, $model->abreviacion, $model->cuenta, $model->banco->id, $model->tipoSociedad->id]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
{
|
||||
return $this->update($model, ['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'], $new_data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user