Add update for form
This commit is contained in:
parent
104b04b639
commit
288533efd3
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Formtemplate;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
||||
class FormtemplateUpdateAction
|
||||
{
|
||||
use AsAction;
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'config' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public function handle(Formtemplate $formtemplate, array $attributes): void
|
||||
{
|
||||
$formtemplate->update($attributes);
|
||||
}
|
||||
|
||||
public function asController(Formtemplate $formtemplate, ActionRequest $request): JsonResponse
|
||||
{
|
||||
$this->handle($formtemplate, $request->validated());
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
}
|
|
@ -18,7 +18,12 @@ class FormtemplateResource extends JsonResource
|
|||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return parent::toArray($request);
|
||||
return [
|
||||
...parent::toArray($request),
|
||||
'links' => [
|
||||
'update' => route('formtemplate.update', ['formtemplate' => $this->getModel()]),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ use App\Group\Actions\GroupBulkstoreAction;
|
|||
use App\Group\Actions\GroupIndexAction;
|
||||
use App\Form\Actions\FormtemplateIndexAction;
|
||||
use App\Form\Actions\FormtemplateStoreAction;
|
||||
use App\Form\Actions\FormtemplateUpdateAction;
|
||||
use App\Initialize\Actions\InitializeAction;
|
||||
use App\Initialize\Actions\InitializeFormAction;
|
||||
use App\Initialize\Actions\NamiGetSearchLayerAction;
|
||||
|
@ -146,4 +147,5 @@ Route::group(['middleware' => 'auth:web'], function (): void {
|
|||
// ------------------------------------ form -----------------------------------
|
||||
Route::get('/formtemplate', FormtemplateIndexAction::class)->name('formtemplate.index');
|
||||
Route::post('/formtemplate', FormtemplateStoreAction::class)->name('formtemplate.store');
|
||||
Route::patch('/formtemplate/{formtemplate}', FormtemplateUpdateAction::class)->name('formtemplate.update');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue