Skip to content

Commit

Permalink
[8.0] Developer friendly message if no Prunable Models found (#38108)
Browse files Browse the repository at this point in the history
* Developer friendly message if no Prunable Models found

* Update PruneCommand.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
JayBizzle and taylorotwell authored Jul 23, 2021
1 parent e3c58d1 commit dbfad18
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Illuminate/Database/Console/PruneCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit dbfad18

Please sign in to comment.