versions() as $version) { Storage::delete($version->get('path')); } if (empty(Storage::files($path->versionsDirPath()))) { Storage::deleteDirectory($path->versionsDirPath()); } } public function rename(MediaPath $old, MediaPath $new): void { foreach ($old->versions() as $version) { Storage::move( $version->get('path'), $new->versionsDirPath().'/'.$new->filename().$version->get('size').$version->get('ext') ); } } }