Edit Pie
This commit is contained in:
31
app/src/Controller/API/Ventas/Pies.php
Normal file
31
app/src/Controller/API/Ventas/Pies.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Controller\API\{withJson, emptyBody};
|
||||
use Incoviba\Controller\withRedis;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyRedis, EmptyResult};
|
||||
use Incoviba\Service;
|
||||
|
||||
class Pies
|
||||
{
|
||||
use withRedis, withJson, emptyBody;
|
||||
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\Pie $pieService, int $pie_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'pie_id' => $pie_id,
|
||||
'input' => $body,
|
||||
'edited' => false
|
||||
];
|
||||
error_log(var_export($output,true).PHP_EOL,3,'/logs/pies');
|
||||
try {
|
||||
$pie = $pieService->getById($pie_id);
|
||||
$pieService->edit($pie, (array) $body);
|
||||
$output['edited'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
@ -71,6 +71,11 @@ class Ventas
|
||||
}
|
||||
return $view->render($response, 'ventas.propiedades.edit', compact('propiedad', 'proyecto', 'tiposUnidades', 'unidades', 'venta'));
|
||||
}
|
||||
public function pie(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $service, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $service->getById($venta_id);
|
||||
return $view->render($response, 'ventas.pies.edit', compact('venta'));
|
||||
}
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, View $view, Repository\Region $regionRepository, Repository\Proyecto $proyectoRepository): ResponseInterface
|
||||
{
|
||||
$regiones = $regionRepository->fetchAll();
|
||||
|
@ -27,4 +27,8 @@ class Pie
|
||||
{
|
||||
return $this->cuotaService->add($data);
|
||||
}
|
||||
public function edit(Model\Venta\Pie $pie, array $data): Model\Venta\Pie
|
||||
{
|
||||
return $this->pieRepository->edit($pie, $data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user