Mercurial > packages > magicforger
diff src/Generator/Generator.php @ 34:f65ab84ee47f default
merge with codex
| author | luka |
|---|---|
| date | Wed, 10 Sep 2025 21:00:47 -0400 |
| parents | 1a717c7b211f |
| children | 76584181267a |
line wrap: on
line diff
--- a/src/Generator/Generator.php Sat Dec 02 10:20:32 2023 -0500 +++ b/src/Generator/Generator.php Wed Sep 10 21:00:47 2025 -0400 @@ -1,6 +1,6 @@ <?php -namespace Wizzard\MagicForger\Generator; +namespace Wizard\MagicForger\Generator; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputInterface; @@ -29,8 +29,9 @@ */ public function handle() { + // First we need to ensure that the table exists, then we can - if (!$this->tableExists($this->getTableInput())) { + if (! $this->tableExists($this->getTableInput())) { $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.'); return false; @@ -46,6 +47,7 @@ $this->input->setOption('controller', true); $this->input->setOption('model', true); $this->input->setOption('request', true); + $this->input->setOption('view', true); $this->input->setOption('route', true); } @@ -73,6 +75,10 @@ $this->createRequest(); } + if ($this->option('view')) { + $this->createView(); + } + if ($this->option('route')) { $this->createRoute(); } @@ -80,34 +86,27 @@ /** * Get the console command options. - * - * @return array */ - protected function getOptions() + protected function getOptions(): array { return array_merge(parent::getOptions(), [ ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, seeder, factory, policy, resource controller, and form request classes for the table.'], ['controller', 'c', InputOption::VALUE_NONE, 'Generate a controller class for the table.'], ['model', 'm', InputOption::VALUE_NONE, 'Generate a model class for the table.'], ['request', 'r', InputOption::VALUE_NONE, 'Generate base request classes for the table.'], + ['view', '', InputOption::VALUE_NONE, 'Generate base views for the table.'], ['route', 'w', InputOption::VALUE_NONE, 'Generate base routes classes for the table.'], ]); } /** * Interact further with the user if they were prompted for missing arguments. - * - * @return void */ - protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output) - { - } + protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output): void {} - protected function getStub() - { - } + protected function getStub(): void {} - protected function createController() + protected function createController(): void { $this->call('mf:controller', ['table' => $this->getTableInput(), '--fresh' => $this->option('fresh')]); } @@ -122,6 +121,11 @@ $this->call('mf:request', ['table' => $this->getTableInput(), '--fresh' => $this->option('fresh'), '--all' => true]); } + protected function createView() + { + $this->call('mf:view', ['table' => $this->getTableInput(), '--fresh' => $this->option('fresh'), '--all' => true]); + } + protected function createRoute() { $this->call('mf:route', ['table' => $this->getTableInput(), '--fresh' => $this->option('fresh')]);
