route()->action['as'] == 'api.file.store') { app()->bind('collection', function () use ($request) { return Collection::where('name', $request->route('collections_name'))->get(); }); app()->singleton('getFileUuid', function () { return Str::uuid(); }); } if ($request->route()->action['as'] == 'api.file.private') { app()->bind('collection', function () use ($request) { return Collection::where('name', $request->route('collections_name'))->get(); }); } return $next($request); } }