Mercurial > packages > magicforger
annotate src/Generator/BaseGenerator.php @ 4:a20439b1c9d3
Added Model generator and other updates.
| author | luka |
|---|---|
| date | Tue, 27 Jun 2023 20:16:55 -0400 |
| parents | 6468684362c2 |
| children | b0b2e79ad8e6 |
| rev | line source |
|---|---|
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
1 <?php |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
2 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
3 namespace Wizzard\MagicForger\Generator; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
4 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
5 use DB; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
6 |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
7 use Illuminate\Console\GeneratorCommand; |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
8 use Illuminate\Support\Str; |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
9 use Symfony\Component\Console\Attribute\AsCommand; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
10 use Symfony\Component\Console\Input\InputInterface; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
11 use Symfony\Component\Console\Input\InputOption; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
12 use Symfony\Component\Console\Output\OutputInterface; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
13 |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
14 use Wizzard\MagicForger\Generator\Replacer; |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
15 |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
16 abstract class BaseGenerator extends GeneratorCommand |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
17 { |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
18 use Replacer; |
| 2 | 19 |
| 20 /** | |
| 21 * The console command description. | |
| 22 * | |
| 23 * @var string | |
| 24 */ | |
| 25 protected $schema; | |
| 26 | |
| 27 /** | |
| 28 * The console command description. | |
| 29 * | |
| 30 * @var string | |
| 31 */ | |
| 32 protected $tables; | |
| 33 | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
34 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
35 * Execute the console command. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
36 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
37 public function handle() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
38 { |
| 4 | 39 |
| 40 | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
41 // First we need to ensure that the table exists, then we can |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
42 if (! $this->tableExists($this->getTableInput())) { |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
43 $this->components->error('The table: "'.$this->getTableInput().'" does not exist in the database.'); |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
44 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
45 return false; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
46 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
47 |
| 4 | 48 $path = $this->getPath(); |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
49 |
| 4 | 50 $file = $this->getFile($path); |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
51 |
| 4 | 52 $file = $this->apply_replacements($file); |
| 53 | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
54 $this->makeDirectory($path); |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
55 |
| 4 | 56 $this->files->put($path, $this->sortImports($file)); |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
57 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
58 $info = $this->type; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
59 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
60 $this->components->info(sprintf('%s [%s] created successfully.', $info, $path)); |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
61 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
62 |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
63 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
64 * Override the original so that we can prompt for a table with autocomplete. |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
65 * |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
66 */ |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
67 protected function promptForMissingArguments(InputInterface $input, OutputInterface $output) |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
68 { |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
69 $prompted = false; |
| 2 | 70 if(is_null($input->getArgument('table'))) { |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
71 $prompted = true; |
| 2 | 72 $table = null; |
| 73 while ($table === null) { | |
| 74 $table = $this->components->askWithCompletion( | |
| 75 'What Table should we use?', | |
| 76 $this->possibleTables() | |
| 77 ); | |
| 78 } | |
| 79 | |
| 80 $input->setArgument('table', $table); | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
81 } |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
82 |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
83 parent::promptForMissingArguments($input, $output); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
84 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
85 // This will get missed if we prompt here but not in the parent |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
86 if($prompted) { |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
87 $this->afterPromptingForMissingArguments($input, $output); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
88 } |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
89 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
90 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
91 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
92 * Get the console command arguments. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
93 * |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
94 * @return array |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
95 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
96 protected function getArguments() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
97 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
98 return [ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
99 ['table', InputOption::VALUE_REQUIRED, 'The table to generate files for.'], |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
100 ]; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
101 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
102 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
103 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
104 * Prompt for missing input arguments using the returned questions. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
105 * |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
106 * @return array |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
107 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
108 protected function promptForMissingArgumentsUsing() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
109 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
110 return [ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
111 ]; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
112 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
113 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
114 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
115 * Get the console command options. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
116 * |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
117 * @return array |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
118 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
119 protected function getOptions() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
120 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
121 return [ |
| 4 | 122 ['fresh', 'f', InputOption::VALUE_NONE, 'Start from the stub or use existing if possible.'], |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
123 ]; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
124 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
125 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
126 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
127 * Interact further with the user if they were prompted for missing arguments. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
128 * |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
129 * @return void |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
130 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
131 protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output) |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
132 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
133 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
134 |
| 2 | 135 /** |
| 4 | 136 * Determines if the file exists |
| 137 */ | |
| 138 protected function fileExists(string $path): bool | |
| 139 { | |
| 140 return $this->files->exists($path); | |
| 141 } | |
| 142 | |
| 143 /** | |
| 2 | 144 * Gets the file that will be worked on. If there is already an existing file |
| 145 * then we can open that. However if we are forcing the operation, then we | |
| 146 * will start with an empty stub. | |
| 147 * | |
| 148 */ | |
| 149 protected function getFile($name) | |
| 150 { | |
| 4 | 151 if ((! $this->hasOption('fresh') || |
| 152 ! $this->option('fresh')) && | |
| 153 $this->fileExists($name)) { | |
| 2 | 154 //Working with an existing file |
| 4 | 155 return $this->files->get($name); |
| 2 | 156 } |
| 157 | |
| 158 //Working with a stub | |
| 159 return $this->files->get($this->getStub()); | |
| 160 } | |
| 161 | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
162 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
163 * Get the desired class table from the input. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
164 * |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
165 * @return string |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
166 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
167 protected function getTableInput() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
168 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
169 return trim($this->argument('table')); |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
170 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
171 |
| 4 | 172 |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
173 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
174 * Determines if the table exists in the current database |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
175 */ |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
176 protected function tableExists(string $table_name): bool |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
177 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
178 return in_array($table_name, $this->getTables()); |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
179 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
180 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
181 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
182 * Get a list of possible table names. |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
183 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
184 protected function possibleTables() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
185 { |
| 2 | 186 return $this->getTables(); |
| 187 } | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
188 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
189 /** |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
190 * Get the tables in the schema |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
191 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
192 protected function getTables() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
193 { |
| 2 | 194 if (is_null($this->tables)) { |
| 195 $this->tables = collect($this->getSchema()->listTableNames())->all(); | |
| 196 } | |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
197 |
| 2 | 198 return $this->tables; |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
199 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
200 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
201 /** |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
2
diff
changeset
|
202 * Get the database schema for DB interactions |
|
1
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
203 */ |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
204 protected function getSchema() |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
205 { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
206 if (is_null($this->schema)) { |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
207 $this->schema = DB::connection()->getDoctrineSchemaManager(); |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
208 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
209 |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
210 return $this->schema; |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
211 } |
|
ca36acd2bef2
Have a base going, there is definitly a lot wrong with some of the files and the general structure but overall, it's a starting point
luka
parents:
diff
changeset
|
212 } |
