1010
1111class SeedCommand extends Command
1212{
13- const SEEDERS_NAMESPACE_PREFIX = 'Database\Seeders \\' ;
13+ const SEEDERS_NAMESPACE_PREFIX = 'Database \\ Seeders \\' ;
1414
1515 /** @var Filesystem */
1616 protected $ filesystem ;
@@ -22,6 +22,8 @@ class SeedCommand extends Command
2222 */
2323 protected $ signature = 'cmd:db:seed
2424 {--c|class= : The seeder to run }
25+ {--all : Run all registered seed files }
26+ {--force : Force the operation to run when in production }
2527 ' ;
2628
2729 /**
@@ -41,15 +43,33 @@ public function __construct()
4143
4244 public function handle ()
4345 {
46+ if ($ this ->option ('all ' )){
47+ $ this ->runSeed ();
48+ exit ;
49+ }
50+
4451 $ seeders = Arr::wrap ($ this ->option ('class ' )) ?: $ this ->getSeedClass ();
4552
4653 foreach ($ seeders as $ seeder ) {
47- $ this ->call ('db:seed ' , [
48- '--class ' => $ this ->getSeederWithNamespace ($ seeder ),
49- ]);
54+ $ this ->runSeed ($ seeder );
5055 }
5156 }
5257
58+ private function runSeed (?string $ class = null ) :void
59+ {
60+ $ options = [];
61+
62+ if ($ class ){
63+ $ options ['--class ' ] = $ this ->getSeederWithNamespace ($ class );
64+ }
65+
66+ if ($ force = $ this ->option ('force ' )){
67+ $ options ['--force ' ] = $ force ;
68+ }
69+
70+ $ this ->call ("db:seed " , $ options );
71+ }
72+
5373 private function getSeederWithNamespace (string $ seeder ) :string
5474 {
5575 if (Str::startsWith ($ seeder , self ::SEEDERS_NAMESPACE_PREFIX )){
0 commit comments