diff --git a/src/Illuminate/Database/Console/Seeds/SeedCommand.php b/src/Illuminate/Database/Console/Seeds/SeedCommand.php index 2c5ab34bb72..e23bed973f6 100644 --- a/src/Illuminate/Database/Console/Seeds/SeedCommand.php +++ b/src/Illuminate/Database/Console/Seeds/SeedCommand.php @@ -5,6 +5,7 @@ use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; use Illuminate\Console\Prohibitable; +use Illuminate\Console\View\Components\TwoColumnDetail; use Illuminate\Database\ConnectionResolverInterface as Resolver; use Illuminate\Database\Eloquent\Model; use Symfony\Component\Console\Attribute\AsCommand; @@ -56,6 +57,8 @@ public function __construct(Resolver $resolver) */ public function handle() { + $isVerbose = $this->output->isVerbose(); + if ($this->isProhibited() || ! $this->confirmToProceed()) { return Command::FAILURE; @@ -67,11 +70,31 @@ public function handle() $this->resolver->setDefaultConnection($this->getDatabase()); - Model::unguarded(function () { - $seeder = $this->getSeeder(); + $seeder = $this->getSeeder(); + + $startTime = microtime(true); + + $name = get_class($seeder); + + with(new TwoColumnDetail($this->output))->render( + $isVerbose + ? sprintf('%s %s', $name, $this->resolver->getDefaultConnection()) + : $name, + 'RUNNING' + ); + + $this->output?->writeln(''); + + Model::unguarded(fn () => $seeder->__invoke()); + + $runTime = number_format((microtime(true) - $startTime) * 1000); - $this->components->task(get_class($seeder), $seeder); - }); + with(new TwoColumnDetail($this->output))->render( + $isVerbose + ? sprintf('%s %s', $name, $this->resolver->getDefaultConnection()) + : $name, + "$runTime ms DONE" + ); $this->output?->writeln('');