Implemented repository mapper, and venta show
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Service;
|
||||
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Venta
|
||||
{
|
||||
@ -10,6 +12,16 @@ class Venta
|
||||
protected Repository\Venta\EstadoVenta $estadoVentaRepository
|
||||
) {}
|
||||
|
||||
public function getById(int $venta_id): Model\Venta
|
||||
{
|
||||
return ($this->ventaRepository->fetchById($venta_id))
|
||||
->addFactory('estados', (new Implement\Repository\Factory())
|
||||
->setCallable([$this->estadoVentaRepository, 'fetchByVenta'])
|
||||
->setArgs([$venta_id]))
|
||||
->addFactory('currentEstado', (new Implement\Repository\Factory())
|
||||
->setCallable([$this->estadoVentaRepository, 'fetchCurrentByVenta'])
|
||||
->setArgs([$venta_id]));
|
||||
}
|
||||
public function getByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$ventas = $this->ventaRepository->fetchByProyecto($proyecto_id);
|
||||
@ -19,4 +31,11 @@ class Venta
|
||||
}
|
||||
return $ventas;
|
||||
}
|
||||
public function getByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta
|
||||
{
|
||||
$venta = $this->ventaRepository->fetchByProyectoAndUnidad($proyecto_nombre, $unidad_descripcion);
|
||||
$venta->addFactory('estados', ['callable' => [$this->estadoVentaRepository, 'fetchByVenta'], 'args' => [$venta->id]]);
|
||||
$venta->addFactory('currentEstado', ['callable' => [$this->estadoVentaRepository, 'fetchCurrentByVenta'], 'args' => [$venta->id]]);
|
||||
return $venta;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user