comparison src/Generator/Generator.php @ 3:6468684362c2

It works! Created a controller, no update insert but it works
author luka
date Tue, 27 Jun 2023 15:32:47 -0400
parents
children b0b2e79ad8e6 4bb4daa9e3f1
comparison
equal deleted inserted replaced
2:cf9993c5c7df 3:6468684362c2
1 <?php
2
3 namespace Wizzard\MagicForger\Generator;
4
5 use DB;
6
7 use Symfony\Component\Console\Attribute\AsCommand;
8 use Symfony\Component\Console\Input\InputInterface;
9 use Symfony\Component\Console\Input\InputOption;
10 use Symfony\Component\Console\Output\OutputInterface;
11 use Illuminate\Support\Str;
12
13 use Wizzard\MagicForger\Generator\BaseGenerator;
14 use Wizzard\MagicForger\Replacer;
15
16 #[AsCommand(name: 'mf')]
17 class Generator extends BaseGenerator
18 {
19 /**
20 * The name and signature of the console command.
21 *
22 * @var string
23 */
24 protected $name = 'mf';
25
26 /**
27 * The console command description.
28 *
29 * @var string
30 */
31 protected $description = 'Generates any (or all) of the available files.';
32
33
34 /**
35 * Execute the console command.
36 */
37 public function handle()
38 {
39
40 // First we need to ensure that the table exists, then we can
41 if (!$this->tableExists($this->getTableInput())) {
42 $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.');
43
44 return false;
45 }
46
47 if ($this->option('all')) {
48 /* $this->input->setOption('factory', true); */
49 /* $this->input->setOption('seed', true); */
50 /* $this->input->setOption('migration', true); */
51 $this->input->setOption('controller', true);
52 /* $this->input->setOption('model', true); */
53 }
54
55 /* if ($this->option('factory')) { */
56 /* $this->createFactory(); */
57 /* } */
58
59 /* if ($this->option('migration')) { */
60 /* $this->createMigration(); */
61 /* } */
62
63 /* if ($this->option('seed')) { */
64 /* $this->createSeeder(); */
65 /* } */
66
67 if ($this->option('controller')) {
68 $this->createController();
69 }
70
71 /* if ($this->option('model')) { */
72 /* $this->createModel(); */
73 /* } */
74
75 }
76
77 /**
78 * Get the console command options.
79 *
80 * @return array
81 */
82 protected function getOptions()
83 {
84 return [
85 ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, seeder, factory, policy, resource controller, and form request classes for the table.'],
86 ['controller', 'c', InputOption::VALUE_NONE, 'Generate a controller class for the table.'],
87 ];
88 }
89
90 /**
91 * Interact further with the user if they were prompted for missing arguments.
92 *
93 * @return void
94 */
95 protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output)
96 {
97 }
98
99 protected function getStub()
100 {
101 }
102
103 protected function createController()
104 {
105 $this->call('mf:controller', ['table' => $this->getTableInput()]);
106 }
107 }