33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
|
<?php
|
||
|
namespace Incoviba\Controller\API\Ventas;
|
||
|
|
||
|
use PDOException;
|
||
|
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\{EmptyResult,EmptyRedis};
|
||
|
use Incoviba\Service;
|
||
|
|
||
|
class PropiedadesUnidades
|
||
|
{
|
||
|
use emptyBody, withJson, withRedis;
|
||
|
|
||
|
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||
|
Service\Venta\PropiedadUnidad $propiedadUnidadService, int $pu_id): ResponseInterface
|
||
|
{
|
||
|
$body = $request->getParsedBody();
|
||
|
$output = [
|
||
|
'propiedad_unidad_id' => $pu_id,
|
||
|
'input' => $body,
|
||
|
'edited' => false
|
||
|
];
|
||
|
try {
|
||
|
$pu = $propiedadUnidadService->getById($pu_id);
|
||
|
$propiedadUnidadService->edit($pu, (array) $body);
|
||
|
$output['edited'] = true;
|
||
|
} catch (PDOException | EmptyResult) {}
|
||
|
return $this->withJson($response, $output);
|
||
|
}
|
||
|
}
|