Edit Proveedores

This commit is contained in:
Juan Pablo Vial
2024-12-03 17:35:29 -03:00
parent 42e1dcdff7
commit 187b6f6f05
9 changed files with 232 additions and 49 deletions

View File

@ -22,6 +22,18 @@ class Proveedores extends Ideal\Controller
} catch (Implement\Exception\EmptyResult) {}
return $this->withJson($response, $output);
}
public function get(ServerRequestInterface $request, ResponseInterface $response,
Service\Inmobiliaria\Proveedor $proveedorService, int $proveedor_rut): ResponseInterface
{
$output = [
'proveedor_rut' => $proveedor_rut,
'proveedor' => null,
];
try {
$output['proveedor'] = $proveedorService->getById($proveedor_rut);
} catch (Implement\Exception\EmptyResult) {}
return $this->withJson($response, $output);
}
public function add(ServerRequestInterface $request, ResponseInterface $response,
Service\Inmobiliaria\Proveedor $proveedorService): ResponseInterface
{
@ -54,7 +66,8 @@ class Proveedores extends Ideal\Controller
foreach ($input['proveedores'] as $json) {
$data = json_decode($json, true);
try {
$output['proveedores'] []= $proveedorService->edit($data);
$proveedor = $proveedorService->getById($data['rut']);
$output['proveedores'] []= $proveedorService->edit($proveedor, $data);
$output['success'] []= true;
} catch (Implement\Exception\EmptyResult) {
$output['success'] []= false;