route()->action['as'] == 'api.files.store') && is_null($request->file('file'))) { $file = File::find($request->file); if (!is_null($file)) { $Collection = Collection::where('name', $request->route('collection_name'))->firstOrFail(); if (Storage::disk($Collection->disk)->exists($file->server_path . $file->uuid . '.' . $Collection->ext)) { app()->bind('file', function () use ($file) { return $file; }); } } } if ($request->route()->action['as'] == 'api.files.show') { $file = File::findOrFail($request->route('uuid')); $Collection = Collection::where('name', $request->route('collection_name'))->firstOrFail(); if (Storage::disk($Collection->disk)->exists($file->server_path . $file->uuid . '.' . $Collection->ext)) { app()->bind('file', function () use ($file) { return $file; }); }else{ abort(404); } } if ($request->route()->action['as'] == 'api.files.update') { $file = File::findOrFail($request->route('uuid')); $Collection = Collection::where('name', $request->route('collection_name'))->firstOrFail(); if (Storage::disk($Collection->disk)->exists($file->server_path . $file->uuid . '.' . $Collection->ext)) { app()->bind('file', function () use ($file) { return $file; }); }else{ abort(404); } } if ($request->route()->action['as'] == 'api.files.destroy') { $file = File::findOrFail($request->route('uuid')); $Collection = Collection::withTrashed()->where('name', $request->route('collection_name'))->firstOrFail(); if (Storage::disk($Collection->disk)->exists($file->server_path . $file->uuid . '.' . $Collection->ext)) { app()->bind('file', function () use ($file) { return $file; }); }else{ abort(404); } } return $next($request); } }