thinktomorrow /
chief
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Thinktomorrow\Chief\App\Console; |
||||
| 4 | |||||
| 5 | class Seed extends BaseCommand |
||||
| 6 | { |
||||
| 7 | protected $signature = 'chief:seed |
||||
| 8 | {seeder=DatabaseSeeder : the classname of the seeder. } |
||||
| 9 | {--force}'; |
||||
| 10 | protected $description = 'This will run the seeders to inject new data into your project database.'; |
||||
| 11 | |||||
| 12 | /** |
||||
| 13 | * @return void |
||||
| 14 | */ |
||||
| 15 | public function handle() |
||||
| 16 | { |
||||
| 17 | if (app()->environment() != 'local' && ! $this->option('force')) { |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 18 | throw new \Exception('You can only run the seeder in the local environment since this will inject a ton of default data'); |
||||
| 19 | } |
||||
| 20 | |||||
| 21 | if (app()->environment() != 'local' && $this->option('force')) { |
||||
| 22 | if (! $this->confirm('You are about to inject default seeding data in the ' . app()->environment() . ' database! Are you sure?')) { |
||||
| 23 | $this->info('You are welcome. I have just saved your job.'); |
||||
| 24 | |||||
| 25 | return; |
||||
| 26 | } |
||||
| 27 | } |
||||
| 28 | |||||
| 29 | $seederClass = $this->argument('seeder'); |
||||
| 30 | app($seederClass)->run(); |
||||
|
0 ignored issues
–
show
It seems like
$seederClass can also be of type array; however, parameter $abstract of app() does only seem to accept null|string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 31 | |||||
| 32 | $this->info($seederClass . ' has run successfully.'); |
||||
| 33 | } |
||||
| 34 | } |
||||
| 35 |