I have an error in the variable name here, it should be:
// if doing this routinely, as in some job you can clear out the destination first:
$oldBackupImages = Storage::disk('imagesBackup')->allFiles();
if ($oldBackupImages) {
Storage::disk('imagesBackup')->delete($oldBackupImages);
}
I am sorry, but to clarify, was the code generated using an effortless and sorrowful LLM? If so, it makes sense it's invalid - there's no such method in the general local file-system driver (Laravel v10.38.1):
> Storage::disk('local')->getDriver()->getAdapter();
Error Call to undefined method League\Flysystem\Filesystem::getAdapter().