diff --git a/src/Commands/ClearCommand.php b/src/Commands/ClearCommand.php index e610df3c2..bf3968e43 100644 --- a/src/Commands/ClearCommand.php +++ b/src/Commands/ClearCommand.php @@ -6,6 +6,7 @@ use Illuminate\Console\ConfirmableTrait; use Illuminate\Database\Eloquent\Collection; use Spatie\MediaLibrary\MediaRepository; +use Spatie\MediaLibrary\Models\Media; class ClearCommand extends Command { @@ -31,7 +32,16 @@ public function handle() return; } - $this->getMediaItems()->each->delete(); + $mediaItems = $this->getMediaItems(); + + $progressBar = $this->output->createProgressBar($mediaItems->count()); + + $mediaItems->each(function (Media $media) use ($progressBar) { + $media->delete(); + $progressBar->advance(); + }); + + $progressBar->finish(); $this->info('All done!'); }