diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index 1c362c06..84774707 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -282,6 +282,21 @@ public function paginate(Request $request): LengthAwarePaginator }); } + /** + * Handle the request. + */ + public function handleFormRequest(Request $request, Model $model): void + { + $this->validateFormRequest($request, $model); + + $this->resolveFields($request) + ->authorized($request, $model) + ->visible($request->method() === 'POST' ? 'create' : 'update') + ->persist($request, $model); + + $model->save(); + } + /** * Register the routes. */