Edit Proveedores
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user