Ventas->Listado->Ventas
This commit is contained in:
45
app/src/Repository/Venta/Propiedad.php
Normal file
45
app/src/Repository/Venta/Propiedad.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace Incoviba\Repository\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Propiedad extends Ideal\Repository
|
||||
{
|
||||
public function __construct(Define\Connection $connection, protected Unidad $unidadRepository)
|
||||
{
|
||||
parent::__construct($connection);
|
||||
$this->setTable('propiedad');
|
||||
}
|
||||
|
||||
public function create(?array $data = null): Define\Model
|
||||
{
|
||||
$map = [
|
||||
'unidad_principal' => [
|
||||
'property' => 'unidades',
|
||||
'function' => function($data) {
|
||||
return $this->unidadRepository->fetchByPropiedad($data['id']);
|
||||
}
|
||||
],
|
||||
'estado' => [
|
||||
'function' => function($data) {
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
||||
return $this->parseData(new Model\Venta\Propiedad(), $data, $map);
|
||||
}
|
||||
public function save(Define\Model $model): Define\Model
|
||||
{
|
||||
$model->id = $this->saveNew(
|
||||
['unidad_principal', 'estacionamientos', 'bodegas', 'estado'],
|
||||
[$model->departamentos()[0]->id, null, null, 1]
|
||||
);
|
||||
return $model;
|
||||
}
|
||||
public function edit(Define\Model $model, array $new_data): Define\Model
|
||||
{
|
||||
return $this->update($model, ['unidad_principal', 'estacionamientos', 'bodegas', 'estado'], $new_data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user