| 1 | <?php |
||
| 9 | class SeedGeneratorCommand extends GeneratorCommand |
||
| 10 | { |
||
| 11 | protected $name = 'db-exporter:seeds'; |
||
| 12 | |||
| 13 | protected $description = 'Export your database table data to a seed class.'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var \Elimuswift\DbExporter\DbExportHandler |
||
| 17 | */ |
||
| 18 | protected $handler; |
||
| 19 | |||
| 20 | public function __construct(DbExportHandler $handler) |
||
| 26 | |||
| 27 | //end __construct() |
||
| 28 | |||
| 29 | public function handle() |
||
| 30 | { |
||
| 31 | $database = $this->argument('database'); |
||
| 32 | // Display some helpfull info |
||
| 33 | if (empty($database)) { |
||
| 34 | $this->comment("Preparing the seeder class for database {$this->getDatabaseName()}"); |
||
| 35 | } else { |
||
| 36 | $this->comment("Preparing the seeder class for database {$database}"); |
||
| 37 | } |
||
| 38 | |||
| 39 | // Grab the options |
||
| 40 | $this->fireAction('seed', $database); |
||
| 41 | // Symfony style block messages |
||
| 42 | $formatter = $this->getHelperSet()->get('formatter'); |
||
| 43 | $filename = $this->getFilename(); |
||
| 44 | $errorMessages = [ |
||
| 45 | 'Success!', |
||
| 46 | "Database seed class generated in: {$filename}", |
||
| 47 | ]; |
||
| 48 | $formattedBlock = $formatter->formatBlock($errorMessages, 'info', true); |
||
| 49 | $this->line($formattedBlock); |
||
| 50 | } |
||
| 51 | |||
| 52 | //end fire() |
||
| 53 | |||
| 54 | private function getFilename() |
||
| 60 | |||
| 61 | //end getFilename() |
||
| 62 | }//end class |
||
| 63 |