route()->action['as'] == 'api.files.store') || ($request->route()->action['as'] == "api.files.show") || ($request->route()->action['as'] == 'api.files.update')) { app()->singleton('collection', function () use ($request) { return Collection::where('name', $request->route('collection_name'))->firstOrFail(); }); } if ($request->route()->action['as'] == 'api.file.private') { app()->singleton('collection', function () use ($request) { return Collection::where('name', $request->route('collection_name'))->firstOrFail(); }); } return $next($request); } }