diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 9c67bb08..a1c6e6f9 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -425,9 +425,7 @@ public function resolveFormat(Request $request, Model $model): ?string */ public function persist(Request $request, Model $model, mixed $value): void { - $model->saving(function (Model $model) use ($request, $value): void { - $this->resolveHydrate($request, $model, $value); - }); + $this->resolveHydrate($request, $model, $value); } /** diff --git a/src/Http/Controllers/ResourceController.php b/src/Http/Controllers/ResourceController.php index 1be05b81..2ea827f1 100644 --- a/src/Http/Controllers/ResourceController.php +++ b/src/Http/Controllers/ResourceController.php @@ -19,10 +19,6 @@ class ResourceController extends Controller */ public function index(Request $request, Resource $resource): Response { - if ($resource->getPolicy()) { - $this->authorize('viewAny', $resource->getModel()); - } - $data = $resource->toIndex($request); return ResponseFactory::view( @@ -35,10 +31,6 @@ public function index(Request $request, Resource $resource): Response */ public function create(Request $request, Resource $resource): Response { - if ($resource->getPolicy()) { - $this->authorize('create', $resource->getModel()); - } - $data = $resource->toCreate($request); return ResponseFactory::view( @@ -51,10 +43,6 @@ public function create(Request $request, Resource $resource): Response */ public function store(Request $request, Resource $resource): RedirectResponse { - if ($resource->getPolicy()) { - $this->authorize('create', $resource->getModel()); - } - $model = $resource->getModelInstance(); $resource->handleFormRequest($request, $model); @@ -68,10 +56,6 @@ public function store(Request $request, Resource $resource): RedirectResponse */ public function show(Request $request, Resource $resource, Model $model): Response { - if ($resource->getPolicy()) { - $this->authorize('view', $model); - } - $data = $resource->toShow($request, $model); return ResponseFactory::view( @@ -84,10 +68,6 @@ public function show(Request $request, Resource $resource, Model $model): Respon */ public function edit(Request $request, Resource $resource, Model $model): Response { - if ($resource->getPolicy()) { - $this->authorize('update', $model); - } - $data = $resource->toEdit($request, $model); return ResponseFactory::view( @@ -100,10 +80,6 @@ public function edit(Request $request, Resource $resource, Model $model): Respon */ public function update(Request $request, Resource $resource, Model $model): RedirectResponse { - if ($resource->getPolicy()) { - $this->authorize('update', $model); - } - $resource->handleFormRequest($request, $model); return Redirect::to($resource->modelUrl($model)) @@ -132,10 +108,6 @@ public function destroy(Request $request, Resource $resource, Model $model): Red */ public function restore(Request $request, Resource $resource, Model $model): RedirectResponse { - if ($resource->getPolicy()) { - $this->authorize('restore', $model); - } - $model->restore(); return Redirect::back()