Laravel File Storage delete all files in directory Laravel File Storage delete all files in directory laravel laravel

Laravel File Storage delete all files in directory


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);


Just use it.

 File::cleanDirectory($direction);