Laravel File Storage delete all files in directory
Just use it.
File::cleanDirectory($direction);
I don't think if this is the best way to solve this. But I solved mine calling
use Illuminate\Filesystem\Filesystem;
Then initiate new instance
$file = new Filesystem;
$file->cleanDirectory('storage/app/backgrounds');
use Illuminate\Support\Facades\Storage;
// Get all files in a directory
$files = Storage::allFiles($dir);
// Delete Files
Storage::delete($files);
You can use Filesystem method cleanDirectory
$success = Storage::cleanDirectory($directory);
Please see documentation for more information:
https://laravel.com/api/5.5/Illuminate/Filesystem/Filesystem.html#method_cleanDirectory