Codexshaper /
laravel-database-manager
| 1 | <?php |
||
| 2 | |||
| 3 | namespace CodexShaper\DBM\Commands; |
||
| 4 | |||
| 5 | use Illuminate\Console\Command; |
||
| 6 | use Illuminate\Filesystem\Filesystem; |
||
| 7 | use Symfony\Component\Console\Input\InputOption; |
||
| 8 | |||
| 9 | class DatabaseSeed extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The console command name. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $name = 'dbm:seed'; |
||
| 17 | /** |
||
| 18 | * The console command description. |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $description = 'Seed the Laravel Database Manager'; |
||
| 23 | /** |
||
| 24 | * The database Seeder Path. |
||
| 25 | * |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $seedersPath = __DIR__.'/../../database/seeds/'; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Get Option. |
||
| 32 | * |
||
| 33 | * @return array |
||
| 34 | */ |
||
| 35 | protected function getOptions() |
||
| 36 | { |
||
| 37 | return [ |
||
| 38 | ['force', null, InputOption::VALUE_NONE, 'Force the operation to run when in production', null], |
||
| 39 | ]; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the composer command for the environment. |
||
| 44 | * |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | protected function findComposer() |
||
| 48 | { |
||
| 49 | if (file_exists(getcwd().'/composer.phar')) { |
||
| 50 | return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
||
| 51 | } |
||
| 52 | |||
| 53 | return 'composer'; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Execute the console command. |
||
| 58 | * |
||
| 59 | * @param \Illuminate\Filesystem\Filesystem $filesystem |
||
| 60 | * |
||
| 61 | * @return void |
||
| 62 | */ |
||
| 63 | public function handle(Filesystem $filesystem) |
||
|
0 ignored issues
–
show
|
|||
| 64 | { |
||
| 65 | $this->info('Database Manager Seeding...'); |
||
| 66 | // Seeding Dummy Data |
||
| 67 | $class = 'DatabaseManagerSeeder'; |
||
| 68 | $file = $this->seedersPath.$class.'.php'; |
||
| 69 | if (file_exists($file) && ! class_exists($class)) { |
||
| 70 | require_once $file; |
||
| 71 | } |
||
| 72 | with(new $class())->run(); |
||
| 73 | |||
| 74 | $this->info('Seeding Completed'); |
||
| 75 | } |
||
| 76 | } |
||
| 77 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.