diff --git a/modules/interventi/src/API/v1/Firma.php b/modules/interventi/src/API/v1/Firma.php index 26b28c5b9..0faf49882 100644 --- a/modules/interventi/src/API/v1/Firma.php +++ b/modules/interventi/src/API/v1/Firma.php @@ -4,6 +4,7 @@ namespace Modules\Interventi\API\v1; use API\Interfaces\UpdateInterface; use API\Resource; +use Models\Upload; class Firma extends Resource implements UpdateInterface { @@ -12,6 +13,7 @@ class Firma extends Resource implements UpdateInterface $database = database(); $data = $request['data']; + //$file = Upload::find($data['file_id']); $database->update('in_interventi', [ 'firma_file' => $data['firma_file'], 'firma_data' => $data['firma_data'], diff --git a/src/API/Common/Allegato.php b/src/API/Common/Allegato.php index 952f07c35..e1a489c07 100644 --- a/src/API/Common/Allegato.php +++ b/src/API/Common/Allegato.php @@ -4,8 +4,8 @@ namespace Api\Common; use API\Interfaces\CreateInterface; use API\Resource; +use Models\Upload; use Modules; -use Uploads; class Allegato extends Resource implements CreateInterface { @@ -13,14 +13,17 @@ class Allegato extends Resource implements CreateInterface { $module = Modules::get($request['module']); - $upload = Uploads::upload($_FILES['upload'], [ - 'name' => $request['name'], + $name = !empty($request['name']) ? $request['name'] : null; + $category = !empty($request['category']) ? $request['category'] : null; + + $upload = Upload::build($_FILES['upload'], [ 'id_module' => $module['id'], 'id_record' => $request['id'], - ]); + ], $name, $category); return[ - 'filename' => $upload, + 'id' => $upload->id, + 'filename' => $upload->filename, ]; } }