From f9ad42b9c6dcdc4c63a6f6fe3991fd81607b0f16 Mon Sep 17 00:00:00 2001 From: Mark Beech Date: Thu, 22 Jul 2021 23:01:11 +0100 Subject: [PATCH 1/2] Developer friendly message if no Prunable Models found --- src/Illuminate/Database/Console/PruneCommand.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/PruneCommand.php b/src/Illuminate/Database/Console/PruneCommand.php index 57d7e1186de0..3c177abdc9ee 100644 --- a/src/Illuminate/Database/Console/PruneCommand.php +++ b/src/Illuminate/Database/Console/PruneCommand.php @@ -36,11 +36,19 @@ class PruneCommand extends Command */ public function handle(Dispatcher $events) { + $models = $this->models(); + + if ($models->isEmpty()) { + $this->info('No prunable Models found.'); + + return; + } + $events->listen(ModelsPruned::class, function ($event) { $this->info("{$event->count} [{$event->model}] records have been pruned."); }); - $this->models()->each(function ($model) { + $models->each(function ($model) { $instance = new $model; $chunkSize = property_exists($instance, 'prunableChunkSize') From 25f5a0e47262ccfc90828a65a2c593cd2b1e08e7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 23 Jul 2021 07:40:05 -0500 Subject: [PATCH 2/2] Update PruneCommand.php --- src/Illuminate/Database/Console/PruneCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/PruneCommand.php b/src/Illuminate/Database/Console/PruneCommand.php index 3c177abdc9ee..bba601506828 100644 --- a/src/Illuminate/Database/Console/PruneCommand.php +++ b/src/Illuminate/Database/Console/PruneCommand.php @@ -39,7 +39,7 @@ public function handle(Dispatcher $events) $models = $this->models(); if ($models->isEmpty()) { - $this->info('No prunable Models found.'); + $this->info('No prunable models found.'); return; }