35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Modules\CustomField\Controllers;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Modules\Client\Models\Client;
|
||
|
|
use App\Modules\CustomField\Actions\UpdateCustomFieldValueAction;
|
||
|
|
use App\Modules\CustomField\Models\CustomFieldDefinition;
|
||
|
|
use App\Modules\CustomField\Requests\UpdateCustomFieldValueRequest;
|
||
|
|
use App\Modules\Client\Resources\ClientResource;
|
||
|
|
use App\Modules\Client\Actions\GetClientAction;
|
||
|
|
|
||
|
|
class CustomFieldValueController extends Controller
|
||
|
|
{
|
||
|
|
public function update(
|
||
|
|
UpdateCustomFieldValueRequest $request,
|
||
|
|
Client $client,
|
||
|
|
CustomFieldDefinition $customFieldDefinition,
|
||
|
|
UpdateCustomFieldValueAction $action,
|
||
|
|
GetClientAction $clients
|
||
|
|
): ClientResource {
|
||
|
|
$this->authorize('update', $client);
|
||
|
|
|
||
|
|
$action->handle(
|
||
|
|
$client,
|
||
|
|
$customFieldDefinition,
|
||
|
|
$request->validated('value'),
|
||
|
|
$request->user()
|
||
|
|
);
|
||
|
|
|
||
|
|
// Return the full client so the SPA re-renders all field cards in one round-trip.
|
||
|
|
return ClientResource::make($clients->find($client->id));
|
||
|
|
}
|
||
|
|
}
|