route('resource_name')) ? Str::of(explode('.', $request->route()->getName())[1])->singular()->value() : $request->route('resource_name'); $modelDocument = ModelDocument::where('name', $name) ->with('storePolicy', 'updatePolicy', 'getPolicy', 'deletePolicy', 'restorePolicy')->first(); app()->bind('modelDocument', fn() => $modelDocument); return $next($request); } }