Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Last active October 25, 2019 08:30
Show Gist options
  • Save nasrulhazim/3f057293c5dbac758716242e3c96ed82 to your computer and use it in GitHub Desktop.
Save nasrulhazim/3f057293c5dbac758716242e3c96ed82 to your computer and use it in GitHub Desktop.
Added Progress Bar on Seeding
<?php
namespace App\Traits;
trait SeedingProgressBar
{
public function run()
{
$seeders = $this->seeders;
$this->command->info('Seeding ' . __CLASS__ . '...');
$this->command->getOutput()->progressStart(count($seeders));
foreach ($seeders as $class => $is_class) {
if ($is_class) {
$this->call($class, true);
} else {
$method = $class;
$this->$method();
}
$this->command->getOutput()->progressAdvance();
}
$this->command->getOutput()->progressFinish();
}
}
@nasrulhazim
Copy link
Author

screen shot 2018-06-18 at 2 44 50 pm

@AlexMcowkin
Copy link

hi. how can I use it with laravel 6?
can you give example with databaseed.php?

@AlexMcowkin
Copy link

thank you. will try on weekends

@AlexMcowkin
Copy link

Hello. I have problem.
Illuminate\Contracts\Container\BindingResolutionException : Target class [MessageFactorySeeder] does not exist.

I have DatabaseSeeder and MessageFactorySeeder in one folder.

should I add something to composer?

    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/",
            "Database\\": "database/"
        }
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment