Create progress bar with Laravel (command)

PHOTO EMBED

Sat May 28 2022 09:49:21 GMT+0000 (Coordinated Universal Time)

Saved by @jeromew #laravel

public function handle()
{
     $datas = Model::all();

     $bar = $this->output->createProgressBar($datas->count());

     $datas->each(function ($data) use ($bar) {
         try {
             // do something
         } catch (Exception $e) {
             $this->error('Error');
         }

         $bar->advance();
     });
}
content_copyCOPY