-
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathUpdateImpostazioneController.php
More file actions
32 lines (24 loc) · 921 Bytes
/
UpdateImpostazioneController.php
File metadata and controls
32 lines (24 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Modules\Impostazioni\API\Controllers;
use API\Controllers\BaseController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Models\Setting;
use Modules\Impostazioni\API\Models\UpdateImpostazioneRequest;
use Modules\Impostazioni\API\Models\UpdateImpostazioneResponse;
final class UpdateImpostazioneController extends BaseController
{
public function __invoke(Request $request): JsonResponse
{
$data = $this->_cast($request, UpdateImpostazioneRequest::class);
$id = $request->route('id');
$response = new UpdateImpostazioneResponse();
$impostazione = Setting::find($id);
if (!$impostazione->editable) {
$response->edited = true;
return new JsonResponse($response);
}
$response->edited = \Settings::setValue($impostazione->id, $data->valore);
return new JsonResponse($response);
}
}