31 lines
934 B
PHP
31 lines
934 B
PHP
<?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
|
|
];
|
|
try {
|
|
$pie = $pieService->getById($pie_id);
|
|
$pieService->edit($pie, (array) $body);
|
|
$output['edited'] = true;
|
|
} catch (EmptyResult) {}
|
|
return $this->withJson($response, $output);
|
|
}
|
|
}
|