Servicio y vista
This commit is contained in:
@ -11,17 +11,13 @@ use Incoviba\Service;
|
||||
class Proveedores
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Sociedad $sociedadService,
|
||||
Service\Inmobiliaria\Proveedor $proveedorService,
|
||||
Repository\Inmobiliaria\TipoSociedad $tipoSociedad): ResponseInterface
|
||||
{
|
||||
$sociedades = [];
|
||||
$proveedores = [];
|
||||
try {
|
||||
$sociedades = $sociedadService->getAll('nombre');
|
||||
$proveedores = $proveedorService->getAll('nombre');
|
||||
} catch (EmptyResult) {}
|
||||
$tiposSociedades = [];
|
||||
try {
|
||||
$tiposSociedades = $tipoSociedad->fetchAll('descripcion');
|
||||
} catch (EmptyResult) {}
|
||||
return $view->render($response, 'inmobiliarias.proveedores', compact('sociedades', 'tiposSociedades'));
|
||||
return $view->render($response, 'inmobiliarias.proveedores', compact('proveedores'));
|
||||
}
|
||||
}
|
||||
|
35
app/src/Service/Inmobiliaria/Proveedor.php
Normal file
35
app/src/Service/Inmobiliaria/Proveedor.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Inmobiliaria;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Proveedor extends Ideal\Service
|
||||
{
|
||||
public function __construct(LoggerInterface $logger, protected Repository\Inmobiliaria\Proveedor $proveedorRepository)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function getAll(?string $orderBy = null): array
|
||||
{
|
||||
try {
|
||||
return $this->proveedorRepository->fetchAll($orderBy);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getByRut(int $proveedor_rut): ?Model\Inmobiliaria\Proveedor
|
||||
{
|
||||
try {
|
||||
return $this->proveedorRepository->fetchById($proveedor_rut);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user