25 lines
933 B
PHP
25 lines
933 B
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Controller\Ventas;
|
||
|
|
||
|
use Incoviba\Common\Alias\View;
|
||
|
use Psr\Http\Message\ResponseInterface;
|
||
|
use Psr\Http\Message\ServerRequestInterface;
|
||
|
use Incoviba\Service;
|
||
|
|
||
|
class Precios
|
||
|
{
|
||
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view): ResponseInterface
|
||
|
{
|
||
|
return $view->render($response, 'ventas.precios.list');
|
||
|
}
|
||
|
public function proyecto(ServerRequestInterface $request, ResponseInterface $response, Service\Ventas\Precio $precioService): ResponseInterface
|
||
|
{
|
||
|
$body = $request->getBody();
|
||
|
$json = json_decode($body->getContents());
|
||
|
$proyecto_id = $json->proyecto_id;
|
||
|
$precios = $precioService->getByProyecto($proyecto_id);
|
||
|
$response->getBody()->write(json_encode(['precios' => $precios, 'total' => count($precios)]));
|
||
|
return $response->withHeader('Content-Type', 'application/json');
|
||
|
}
|
||
|
}
|