Total Complexity | 6 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
10 | class Seed extends BaseCommand |
||
11 | { |
||
12 | protected $signature = 'chief:seed |
||
13 | {seeder=DatabaseSeeder : the classname of the seeder. } |
||
14 | {--force}'; |
||
15 | protected $description = 'This will run the seeders to inject new data into your project database.'; |
||
16 | |||
17 | public function handle() |
||
18 | { |
||
19 | if (app()->environment() != 'local' && !$this->option('force')) { |
||
20 | throw new \Exception('You can only run the seeder in the local environment since this will inject a ton of default data'); |
||
21 | } |
||
22 | |||
23 | if (app()->environment() != 'local' && $this->option('force')) { |
||
24 | if (!$this->confirm('You are about to inject default seeding data in the '.app()->environment().' database! Are you sure?')) { |
||
25 | $this->info('You are welcome. I have just saved your job.'); |
||
26 | return; |
||
27 | } |
||
28 | } |
||
29 | |||
30 | $seederClass = $this->argument('seeder'); |
||
31 | app($seederClass)->run(); |
||
32 | |||
33 | $this->info($seederClass.' has run successfully.'); |
||
34 | } |
||
36 |