getPolicy,$collection); return new CollectionResource($collection); } public function store(Request $request) { BasePolicy::allow(app('modelDocument')?->storePolicy); $collection = Collection::create($request->all()); return new CollectionResource($collection); } public function update(Request $request, Collection $collection) { BasePolicy::allow(app('modelDocument')?->updatePolicy, $collection); $collection->update($request->all()); return new CollectionResource($collection); } public function destroy(Collection $collection) { BasePolicy::allow(app('modelDocument')?->{$collection->trashed() ? 'restorePolicy' : 'deletePolicy'},$collection); if ($collection->trashed()) { return $collection->restore(); } return $collection->delete(); } }