@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $this->container['slug'] = Str::slug($this->argument('slug')); |
91 | 91 | $this->container['name'] = Str::studly($this->container['slug']); |
92 | 92 | $this->container['version'] = '1.0'; |
93 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
93 | + $this->container['description'] = 'This is the description for the '.$this->container['name'].' module.'; |
|
94 | 94 | $this->container['location'] = config('modules.default_location'); |
95 | 95 | $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
96 | 96 | $this->container['basename'] = Str::studly($this->container['slug']); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $progress->finish(); |
125 | 125 | |
126 | - event($this->container['slug'] . '.module.made'); |
|
126 | + event($this->container['slug'].'.module.made'); |
|
127 | 127 | |
128 | 128 | $this->info("\nModule generated successfully."); |
129 | 129 | } |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
139 | 139 | $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
140 | 140 | |
141 | - if (!$this->files->isDirectory($root)) { |
|
141 | + if ( ! $this->files->isDirectory($root)) { |
|
142 | 142 | $this->files->makeDirectory($root); |
143 | 143 | } |
144 | 144 | |
145 | 145 | $directory = module_path(null, $this->container['basename'], $location); |
146 | - $source = __DIR__ . '/Stubs/Module'; |
|
146 | + $source = __DIR__.'/Stubs/Module'; |
|
147 | 147 | |
148 | 148 | $this->files->makeDirectory($directory); |
149 | 149 | |
150 | 150 | $sourceFiles = $this->files->allFiles($source, true); |
151 | 151 | |
152 | - if (!empty($this->mapping)) { |
|
152 | + if ( ! empty($this->mapping)) { |
|
153 | 153 | $search = array_keys($this->mapping); |
154 | 154 | $replace = array_values($this->mapping); |
155 | 155 | } |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $contents = $this->replacePlaceholders($file->getContents()); |
159 | 159 | $subPath = $file->getRelativePathname(); |
160 | 160 | |
161 | - if (!empty($this->mapping)) { |
|
161 | + if ( ! empty($this->mapping)) { |
|
162 | 162 | $subPath = str_replace($search, $replace, $subPath); |
163 | 163 | } |
164 | 164 | |
165 | - $filePath = $directory . '/' . $subPath; |
|
165 | + $filePath = $directory.'/'.$subPath; |
|
166 | 166 | |
167 | 167 | // if the file is module.json, replace it with the custom manifest file name |
168 | 168 | if ($file->getFilename() === 'module.json' && $manifest) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $dir = dirname($filePath); |
179 | 179 | |
180 | - if (! $this->files->isDirectory($dir)) { |
|
180 | + if ( ! $this->files->isDirectory($dir)) { |
|
181 | 181 | $this->files->makeDirectory($dir, 0755, true); |
182 | 182 | } |
183 | 183 | |
@@ -210,20 +210,20 @@ discard block |
||
210 | 210 | ]; |
211 | 211 | |
212 | 212 | $replace = [ |
213 | - ucfirst($modelNameSingular) . 'Factory', |
|
213 | + ucfirst($modelNameSingular).'Factory', |
|
214 | 214 | $modelNameSingular, |
215 | 215 | $this->container['slug'], |
216 | 216 | ucfirst($modelName), |
217 | 217 | ucfirst($modelNameSingular), |
218 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
219 | - ucfirst($modelName) . 'TableSeeder', |
|
220 | - ucfirst($modelNameSingular) . 'Controller', |
|
221 | - ucfirst($modelNameSingular) . 'Service', |
|
222 | - ucfirst($modelNameSingular) . 'Repository', |
|
223 | - ucfirst($modelName) . 'Errors', |
|
224 | - 'Store' . ucfirst($modelNameSingular), |
|
218 | + ucfirst($modelName).'DatabaseSeeder', |
|
219 | + ucfirst($modelName).'TableSeeder', |
|
220 | + ucfirst($modelNameSingular).'Controller', |
|
221 | + ucfirst($modelNameSingular).'Service', |
|
222 | + ucfirst($modelNameSingular).'Repository', |
|
223 | + ucfirst($modelName).'Errors', |
|
224 | + 'Store'.ucfirst($modelNameSingular), |
|
225 | 225 | ucfirst($modelNameSingular), |
226 | - ucfirst($modelNameSingular) . 'Observer', |
|
226 | + ucfirst($modelNameSingular).'Observer', |
|
227 | 227 | \Str::snake($modelName), |
228 | 228 | $modelName, |
229 | 229 | ]; |
@@ -247,6 +247,6 @@ discard block |
||
247 | 247 | $modelName = $this->container['slug']; |
248 | 248 | $migrationName = \Str::camel($modelName); |
249 | 249 | $migrationName = \Str::snake($migrationName); |
250 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $migrationName . '_table']); |
|
250 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_'.$migrationName.'_table']); |
|
251 | 251 | } |
252 | 252 | } |
@@ -10,244 +10,244 @@ |
||
10 | 10 | |
11 | 11 | class MakeModuleCommand extends Command |
12 | 12 | { |
13 | - /** |
|
14 | - * The name and signature of the console command. |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $signature = 'generate:module |
|
13 | + /** |
|
14 | + * The name and signature of the console command. |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $signature = 'generate:module |
|
19 | 19 | {slug : The slug of the module}'; |
20 | 20 | |
21 | - /** |
|
22 | - * The console command description. |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $description = 'Create a new module'; |
|
27 | - |
|
28 | - /** |
|
29 | - * The modules instance. |
|
30 | - * |
|
31 | - * @var RepositoryManager |
|
32 | - */ |
|
33 | - protected $module; |
|
34 | - |
|
35 | - /** |
|
36 | - * The filesystem instance. |
|
37 | - * |
|
38 | - * @var Filesystem |
|
39 | - */ |
|
40 | - protected $files; |
|
41 | - |
|
42 | - /** |
|
43 | - * Array to store the configuration details. |
|
44 | - * |
|
45 | - * @var array |
|
46 | - */ |
|
47 | - protected $container; |
|
48 | - |
|
49 | - /** |
|
50 | - * Array of folder mappings. |
|
51 | - * |
|
52 | - * @var Array |
|
53 | - */ |
|
54 | - protected $mapping = [ |
|
55 | - 'Database/Factories' => 'Database/Factories', |
|
56 | - 'Database/Migrations' => 'Database/Migrations', |
|
57 | - 'Database/Seeds' => 'Database/Seeds', |
|
58 | - 'Http/Controllers' => 'Http/Controllers', |
|
59 | - 'Http/Requests' => 'Http/Requests', |
|
60 | - 'Http/Resources' => 'Http/Resources', |
|
61 | - 'ModelObservers' => 'ModelObservers', |
|
62 | - 'Providers' => 'Providers', |
|
63 | - 'Repositories' => 'Repositories', |
|
64 | - 'Services' => 'Services', |
|
65 | - 'Routes' => 'Routes', |
|
66 | - 'Errors' => 'Errors', |
|
67 | - 'Resources' => 'Resources', |
|
68 | - ]; |
|
69 | - |
|
70 | - /** |
|
71 | - * Create a new command instance. |
|
72 | - * |
|
73 | - * @param Filesystem $files |
|
74 | - * @param RepositoryManager $module |
|
75 | - */ |
|
76 | - public function __construct(Filesystem $files, RepositoryManager $module) |
|
77 | - { |
|
78 | - parent::__construct(); |
|
79 | - |
|
80 | - $this->files = $files; |
|
81 | - $this->module = $module; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Execute the console command. |
|
86 | - * |
|
87 | - * @return mixed |
|
88 | - */ |
|
89 | - public function handle() |
|
90 | - { |
|
91 | - $this->container['slug'] = Str::slug($this->argument('slug')); |
|
92 | - $this->container['name'] = Str::studly($this->container['slug']); |
|
93 | - $this->container['version'] = '1.0'; |
|
94 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
95 | - $this->container['location'] = config('modules.default_location'); |
|
96 | - $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
97 | - $this->container['basename'] = Str::studly($this->container['slug']); |
|
98 | - $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
99 | - |
|
100 | - return $this->generate(); |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Generate the module. |
|
105 | - */ |
|
106 | - protected function generate() |
|
107 | - { |
|
108 | - $steps = [ |
|
109 | - 'Generating module...' => 'generateModule', |
|
110 | - 'Optimizing module cache...' => 'optimizeModules', |
|
111 | - 'Generating migrations...' => 'generateMigration', |
|
112 | - ]; |
|
113 | - |
|
114 | - $progress = new ProgressBar($this->output, count($steps)); |
|
115 | - $progress->start(); |
|
116 | - |
|
117 | - foreach ($steps as $message => $function) { |
|
118 | - $progress->setMessage($message); |
|
119 | - |
|
120 | - $this->$function(); |
|
121 | - |
|
122 | - $progress->advance(); |
|
123 | - } |
|
124 | - |
|
125 | - $progress->finish(); |
|
126 | - |
|
127 | - event($this->container['slug'] . '.module.made'); |
|
128 | - |
|
129 | - $this->info("\nModule generated successfully."); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Generate defined module folders. |
|
134 | - */ |
|
135 | - protected function generateModule() |
|
136 | - { |
|
137 | - $location = $this->container['location']; |
|
138 | - $root = module_path(null, '', $location); |
|
139 | - $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
140 | - $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
141 | - |
|
142 | - if (!$this->files->isDirectory($root)) { |
|
143 | - $this->files->makeDirectory($root); |
|
144 | - } |
|
145 | - |
|
146 | - $directory = module_path(null, $this->container['basename'], $location); |
|
147 | - $source = __DIR__ . '/Stubs/Module'; |
|
148 | - |
|
149 | - $this->files->makeDirectory($directory); |
|
150 | - |
|
151 | - $sourceFiles = $this->files->allFiles($source, true); |
|
152 | - |
|
153 | - if (!empty($this->mapping)) { |
|
154 | - $search = array_keys($this->mapping); |
|
155 | - $replace = array_values($this->mapping); |
|
156 | - } |
|
157 | - |
|
158 | - foreach ($sourceFiles as $file) { |
|
159 | - $contents = $this->replacePlaceholders($file->getContents()); |
|
160 | - $subPath = $file->getRelativePathname(); |
|
161 | - |
|
162 | - if (!empty($this->mapping)) { |
|
163 | - $subPath = str_replace($search, $replace, $subPath); |
|
164 | - } |
|
165 | - |
|
166 | - $filePath = $directory . '/' . $subPath; |
|
21 | + /** |
|
22 | + * The console command description. |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $description = 'Create a new module'; |
|
27 | + |
|
28 | + /** |
|
29 | + * The modules instance. |
|
30 | + * |
|
31 | + * @var RepositoryManager |
|
32 | + */ |
|
33 | + protected $module; |
|
34 | + |
|
35 | + /** |
|
36 | + * The filesystem instance. |
|
37 | + * |
|
38 | + * @var Filesystem |
|
39 | + */ |
|
40 | + protected $files; |
|
41 | + |
|
42 | + /** |
|
43 | + * Array to store the configuration details. |
|
44 | + * |
|
45 | + * @var array |
|
46 | + */ |
|
47 | + protected $container; |
|
48 | + |
|
49 | + /** |
|
50 | + * Array of folder mappings. |
|
51 | + * |
|
52 | + * @var Array |
|
53 | + */ |
|
54 | + protected $mapping = [ |
|
55 | + 'Database/Factories' => 'Database/Factories', |
|
56 | + 'Database/Migrations' => 'Database/Migrations', |
|
57 | + 'Database/Seeds' => 'Database/Seeds', |
|
58 | + 'Http/Controllers' => 'Http/Controllers', |
|
59 | + 'Http/Requests' => 'Http/Requests', |
|
60 | + 'Http/Resources' => 'Http/Resources', |
|
61 | + 'ModelObservers' => 'ModelObservers', |
|
62 | + 'Providers' => 'Providers', |
|
63 | + 'Repositories' => 'Repositories', |
|
64 | + 'Services' => 'Services', |
|
65 | + 'Routes' => 'Routes', |
|
66 | + 'Errors' => 'Errors', |
|
67 | + 'Resources' => 'Resources', |
|
68 | + ]; |
|
69 | + |
|
70 | + /** |
|
71 | + * Create a new command instance. |
|
72 | + * |
|
73 | + * @param Filesystem $files |
|
74 | + * @param RepositoryManager $module |
|
75 | + */ |
|
76 | + public function __construct(Filesystem $files, RepositoryManager $module) |
|
77 | + { |
|
78 | + parent::__construct(); |
|
79 | + |
|
80 | + $this->files = $files; |
|
81 | + $this->module = $module; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Execute the console command. |
|
86 | + * |
|
87 | + * @return mixed |
|
88 | + */ |
|
89 | + public function handle() |
|
90 | + { |
|
91 | + $this->container['slug'] = Str::slug($this->argument('slug')); |
|
92 | + $this->container['name'] = Str::studly($this->container['slug']); |
|
93 | + $this->container['version'] = '1.0'; |
|
94 | + $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
95 | + $this->container['location'] = config('modules.default_location'); |
|
96 | + $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
97 | + $this->container['basename'] = Str::studly($this->container['slug']); |
|
98 | + $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
99 | + |
|
100 | + return $this->generate(); |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Generate the module. |
|
105 | + */ |
|
106 | + protected function generate() |
|
107 | + { |
|
108 | + $steps = [ |
|
109 | + 'Generating module...' => 'generateModule', |
|
110 | + 'Optimizing module cache...' => 'optimizeModules', |
|
111 | + 'Generating migrations...' => 'generateMigration', |
|
112 | + ]; |
|
113 | + |
|
114 | + $progress = new ProgressBar($this->output, count($steps)); |
|
115 | + $progress->start(); |
|
116 | + |
|
117 | + foreach ($steps as $message => $function) { |
|
118 | + $progress->setMessage($message); |
|
119 | + |
|
120 | + $this->$function(); |
|
121 | + |
|
122 | + $progress->advance(); |
|
123 | + } |
|
124 | + |
|
125 | + $progress->finish(); |
|
126 | + |
|
127 | + event($this->container['slug'] . '.module.made'); |
|
128 | + |
|
129 | + $this->info("\nModule generated successfully."); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Generate defined module folders. |
|
134 | + */ |
|
135 | + protected function generateModule() |
|
136 | + { |
|
137 | + $location = $this->container['location']; |
|
138 | + $root = module_path(null, '', $location); |
|
139 | + $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
140 | + $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
141 | + |
|
142 | + if (!$this->files->isDirectory($root)) { |
|
143 | + $this->files->makeDirectory($root); |
|
144 | + } |
|
145 | + |
|
146 | + $directory = module_path(null, $this->container['basename'], $location); |
|
147 | + $source = __DIR__ . '/Stubs/Module'; |
|
148 | + |
|
149 | + $this->files->makeDirectory($directory); |
|
150 | + |
|
151 | + $sourceFiles = $this->files->allFiles($source, true); |
|
152 | + |
|
153 | + if (!empty($this->mapping)) { |
|
154 | + $search = array_keys($this->mapping); |
|
155 | + $replace = array_values($this->mapping); |
|
156 | + } |
|
157 | + |
|
158 | + foreach ($sourceFiles as $file) { |
|
159 | + $contents = $this->replacePlaceholders($file->getContents()); |
|
160 | + $subPath = $file->getRelativePathname(); |
|
161 | + |
|
162 | + if (!empty($this->mapping)) { |
|
163 | + $subPath = str_replace($search, $replace, $subPath); |
|
164 | + } |
|
165 | + |
|
166 | + $filePath = $directory . '/' . $subPath; |
|
167 | 167 | |
168 | - // if the file is module.json, replace it with the custom manifest file name |
|
169 | - if ($file->getFilename() === 'module.json' && $manifest) { |
|
170 | - $filePath = str_replace('module.json', $manifest, $filePath); |
|
171 | - } |
|
168 | + // if the file is module.json, replace it with the custom manifest file name |
|
169 | + if ($file->getFilename() === 'module.json' && $manifest) { |
|
170 | + $filePath = str_replace('module.json', $manifest, $filePath); |
|
171 | + } |
|
172 | 172 | |
173 | - // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
174 | - if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
175 | - $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
176 | - } |
|
177 | - $filePath = $this->replacePlaceholders($filePath); |
|
173 | + // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
174 | + if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
175 | + $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
176 | + } |
|
177 | + $filePath = $this->replacePlaceholders($filePath); |
|
178 | 178 | |
179 | - $dir = dirname($filePath); |
|
179 | + $dir = dirname($filePath); |
|
180 | 180 | |
181 | - if (! $this->files->isDirectory($dir)) { |
|
182 | - $this->files->makeDirectory($dir, 0755, true); |
|
183 | - } |
|
184 | - |
|
185 | - $this->files->put($filePath, $contents); |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - protected function replacePlaceholders($contents) |
|
190 | - { |
|
191 | - $modelName = \Str::camel($this->container['slug']); |
|
192 | - $modelNameSingular = \Str::singular($modelName); |
|
193 | - |
|
194 | - $find = [ |
|
195 | - 'DummyFactory', |
|
196 | - 'DummyModelName', |
|
197 | - 'DummyModuleSlug', |
|
198 | - 'DummyModule', |
|
199 | - 'DummyModel', |
|
200 | - 'DummyDatabaseSeeder', |
|
201 | - 'DummyTableSeeder', |
|
202 | - 'DummyController', |
|
203 | - 'DummyService', |
|
204 | - 'DummyRepository', |
|
205 | - 'DummyErrors', |
|
206 | - 'StoreDummy', |
|
207 | - 'DummyResource', |
|
208 | - 'DummyObserver', |
|
209 | - 'DummyTableName', |
|
210 | - 'DummyRoutePrefix', |
|
211 | - ]; |
|
212 | - |
|
213 | - $replace = [ |
|
214 | - ucfirst($modelNameSingular) . 'Factory', |
|
215 | - $modelNameSingular, |
|
216 | - $this->container['slug'], |
|
217 | - ucfirst($modelName), |
|
218 | - ucfirst($modelNameSingular), |
|
219 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
220 | - ucfirst($modelName) . 'TableSeeder', |
|
221 | - ucfirst($modelNameSingular) . 'Controller', |
|
222 | - ucfirst($modelNameSingular) . 'Service', |
|
223 | - ucfirst($modelNameSingular) . 'Repository', |
|
224 | - ucfirst($modelName) . 'Errors', |
|
225 | - 'Store' . ucfirst($modelNameSingular), |
|
226 | - ucfirst($modelNameSingular), |
|
227 | - ucfirst($modelNameSingular) . 'Observer', |
|
228 | - \Str::snake($modelName), |
|
229 | - $modelName, |
|
230 | - ]; |
|
231 | - |
|
232 | - return str_replace($find, $replace, $contents); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Reset module cache of enabled and disabled modules. |
|
237 | - */ |
|
238 | - protected function optimizeModules() |
|
239 | - { |
|
240 | - return $this->callSilent('module:optimize'); |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Generate table migrations. |
|
245 | - */ |
|
246 | - protected function generateMigration() |
|
247 | - { |
|
248 | - $modelName = $this->container['slug']; |
|
249 | - $migrationName = \Str::camel($modelName); |
|
250 | - $migrationName = \Str::snake($migrationName); |
|
251 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $migrationName . '_table']); |
|
252 | - } |
|
181 | + if (! $this->files->isDirectory($dir)) { |
|
182 | + $this->files->makeDirectory($dir, 0755, true); |
|
183 | + } |
|
184 | + |
|
185 | + $this->files->put($filePath, $contents); |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + protected function replacePlaceholders($contents) |
|
190 | + { |
|
191 | + $modelName = \Str::camel($this->container['slug']); |
|
192 | + $modelNameSingular = \Str::singular($modelName); |
|
193 | + |
|
194 | + $find = [ |
|
195 | + 'DummyFactory', |
|
196 | + 'DummyModelName', |
|
197 | + 'DummyModuleSlug', |
|
198 | + 'DummyModule', |
|
199 | + 'DummyModel', |
|
200 | + 'DummyDatabaseSeeder', |
|
201 | + 'DummyTableSeeder', |
|
202 | + 'DummyController', |
|
203 | + 'DummyService', |
|
204 | + 'DummyRepository', |
|
205 | + 'DummyErrors', |
|
206 | + 'StoreDummy', |
|
207 | + 'DummyResource', |
|
208 | + 'DummyObserver', |
|
209 | + 'DummyTableName', |
|
210 | + 'DummyRoutePrefix', |
|
211 | + ]; |
|
212 | + |
|
213 | + $replace = [ |
|
214 | + ucfirst($modelNameSingular) . 'Factory', |
|
215 | + $modelNameSingular, |
|
216 | + $this->container['slug'], |
|
217 | + ucfirst($modelName), |
|
218 | + ucfirst($modelNameSingular), |
|
219 | + ucfirst($modelName) . 'DatabaseSeeder', |
|
220 | + ucfirst($modelName) . 'TableSeeder', |
|
221 | + ucfirst($modelNameSingular) . 'Controller', |
|
222 | + ucfirst($modelNameSingular) . 'Service', |
|
223 | + ucfirst($modelNameSingular) . 'Repository', |
|
224 | + ucfirst($modelName) . 'Errors', |
|
225 | + 'Store' . ucfirst($modelNameSingular), |
|
226 | + ucfirst($modelNameSingular), |
|
227 | + ucfirst($modelNameSingular) . 'Observer', |
|
228 | + \Str::snake($modelName), |
|
229 | + $modelName, |
|
230 | + ]; |
|
231 | + |
|
232 | + return str_replace($find, $replace, $contents); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Reset module cache of enabled and disabled modules. |
|
237 | + */ |
|
238 | + protected function optimizeModules() |
|
239 | + { |
|
240 | + return $this->callSilent('module:optimize'); |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Generate table migrations. |
|
245 | + */ |
|
246 | + protected function generateMigration() |
|
247 | + { |
|
248 | + $modelName = $this->container['slug']; |
|
249 | + $migrationName = \Str::camel($modelName); |
|
250 | + $migrationName = \Str::snake($migrationName); |
|
251 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $migrationName . '_table']); |
|
252 | + } |
|
253 | 253 | } |
@@ -7,40 +7,40 @@ |
||
7 | 7 | |
8 | 8 | class PassportInstallCommand extends Command |
9 | 9 | { |
10 | - /** |
|
11 | - * The name and signature of the console command. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $signature = 'module:passport:install |
|
10 | + /** |
|
11 | + * The name and signature of the console command. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $signature = 'module:passport:install |
|
16 | 16 | {--force : Overwrite keys they already exist} |
17 | 17 | {--length=4096 : The length of the private key}'; |
18 | 18 | |
19 | - /** |
|
20 | - * The console command description. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $description = 'Run the commands necessary to prepare Passport for use'; |
|
19 | + /** |
|
20 | + * The console command description. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $description = 'Run the commands necessary to prepare Passport for use'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Execute the console command. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function handle(ClientRepository $client) |
|
32 | - { |
|
33 | - $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
|
34 | - $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
|
35 | - if (! $oauthClient) { |
|
36 | - $oauthClient = $client->createPasswordGrantClient( |
|
37 | - null, |
|
38 | - config('app.name'), |
|
39 | - 'http://localhost' |
|
40 | - ); |
|
41 | - } |
|
42 | - \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id); |
|
43 | - \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret); |
|
44 | - \DotenvEditor::save(); |
|
45 | - } |
|
26 | + /** |
|
27 | + * Execute the console command. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function handle(ClientRepository $client) |
|
32 | + { |
|
33 | + $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
|
34 | + $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
|
35 | + if (! $oauthClient) { |
|
36 | + $oauthClient = $client->createPasswordGrantClient( |
|
37 | + null, |
|
38 | + config('app.name'), |
|
39 | + 'http://localhost' |
|
40 | + ); |
|
41 | + } |
|
42 | + \DotenvEditor::setKey('PASSWORD_CLIENT_ID', $oauthClient->id); |
|
43 | + \DotenvEditor::setKey('PASSWORD_CLIENT_SECRET', $oauthClient->secret); |
|
44 | + \DotenvEditor::save(); |
|
45 | + } |
|
46 | 46 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $this->call('passport:keys', ['--force' => $this->option('force'), '--length' => $this->option('length')]); |
34 | 34 | $oauthClient = \Core::oauthCLients()->first(['password_client' => 1]); |
35 | - if (! $oauthClient) { |
|
35 | + if ( ! $oauthClient) { |
|
36 | 36 | $oauthClient = $client->createPasswordGrantClient( |
37 | 37 | null, |
38 | 38 | config('app.name'), |
@@ -8,42 +8,42 @@ |
||
8 | 8 | |
9 | 9 | class DummyController extends BaseApiController |
10 | 10 | { |
11 | - /** |
|
12 | - * Path of the sotre form request. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy'; |
|
11 | + /** |
|
12 | + * Path of the sotre form request. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $storeFormRequest = 'App\Modules\DummyModule\Http\Requests\StoreDummy'; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Path of the model resource |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
18 | + /** |
|
19 | + * Path of the model resource |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $modelResource = 'App\Modules\DummyModule\Http\Resources\DummyModel'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * List of all route actions that the base api controller |
|
27 | - * will skip permissions check for them. |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $skipPermissionCheck = []; |
|
25 | + /** |
|
26 | + * List of all route actions that the base api controller |
|
27 | + * will skip permissions check for them. |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $skipPermissionCheck = []; |
|
31 | 31 | |
32 | - /** |
|
33 | - * List of all route actions that the base api controller |
|
34 | - * will skip login check for them. |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - protected $skipLoginCheck = []; |
|
32 | + /** |
|
33 | + * List of all route actions that the base api controller |
|
34 | + * will skip login check for them. |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + protected $skipLoginCheck = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Init new object. |
|
41 | - * |
|
42 | - * @param DummyService $service |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function __construct(DummyService $service) |
|
46 | - { |
|
47 | - parent::__construct($service); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Init new object. |
|
41 | + * |
|
42 | + * @param DummyService $service |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function __construct(DummyService $service) |
|
46 | + { |
|
47 | + parent::__construct($service); |
|
48 | + } |
|
49 | 49 | } |
@@ -6,25 +6,25 @@ |
||
6 | 6 | |
7 | 7 | class StoreDummy extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - // |
|
28 | - ]; |
|
29 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + // |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | } |
@@ -8,16 +8,16 @@ |
||
8 | 8 | |
9 | 9 | class DummyModel extends Model |
10 | 10 | { |
11 | - use SoftDeletes; |
|
12 | - protected $table = 'DummyTableName'; |
|
13 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | - protected $hidden = ['deleted_at']; |
|
15 | - protected $guarded = ['id']; |
|
16 | - public $fillable = []; // Add attributes here |
|
11 | + use SoftDeletes; |
|
12 | + protected $table = 'DummyTableName'; |
|
13 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
14 | + protected $hidden = ['deleted_at']; |
|
15 | + protected $guarded = ['id']; |
|
16 | + public $fillable = []; // Add attributes here |
|
17 | 17 | |
18 | - public static function boot() |
|
19 | - { |
|
20 | - parent::boot(); |
|
21 | - DummyModel::observe(DummyObserver::class); |
|
22 | - } |
|
18 | + public static function boot() |
|
19 | + { |
|
20 | + parent::boot(); |
|
21 | + DummyModel::observe(DummyObserver::class); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,64 +6,64 @@ |
||
6 | 6 | |
7 | 7 | class DummyTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to DummyModelName table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * DummyModelName model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'index', |
|
26 | - 'model' => 'DummyModelName', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'show', |
|
32 | - 'model' => 'DummyModelName', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'store', |
|
38 | - 'model' => 'DummyModelName', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'update', |
|
44 | - 'model' => 'DummyModelName', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'destroy', |
|
50 | - 'model' => 'DummyModelName', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'deleted', |
|
56 | - 'model' => 'DummyModelName', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'restore', |
|
62 | - 'model' => 'DummyModelName', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ] |
|
66 | - ] |
|
67 | - ); |
|
68 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to DummyModelName table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * DummyModelName model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'index', |
|
26 | + 'model' => 'DummyModelName', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'show', |
|
32 | + 'model' => 'DummyModelName', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'store', |
|
38 | + 'model' => 'DummyModelName', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'update', |
|
44 | + 'model' => 'DummyModelName', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'destroy', |
|
50 | + 'model' => 'DummyModelName', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'deleted', |
|
56 | + 'model' => 'DummyModelName', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'restore', |
|
62 | + 'model' => 'DummyModelName', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ] |
|
66 | + ] |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -7,45 +7,45 @@ |
||
7 | 7 | |
8 | 8 | class ReportRepository extends BaseRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * Init new object. |
|
12 | - * |
|
13 | - * @param Report $model |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function __construct(Report $model) |
|
17 | - { |
|
18 | - parent::__construct($model); |
|
19 | - } |
|
10 | + /** |
|
11 | + * Init new object. |
|
12 | + * |
|
13 | + * @param Report $model |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function __construct(Report $model) |
|
17 | + { |
|
18 | + parent::__construct($model); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Render the given report db view based on the given |
|
23 | - * condition. |
|
24 | - * |
|
25 | - * @param mixed $report |
|
26 | - * @param array $conditions |
|
27 | - * @param integer $perPage |
|
28 | - * @return object |
|
29 | - */ |
|
30 | - public function renderReport($report, $conditions = [], $perPage = 0) |
|
31 | - { |
|
32 | - $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report); |
|
33 | - /** |
|
34 | - * Fetch data from the report based on the given conditions. |
|
35 | - */ |
|
36 | - $report = \DB::table($report->view_name); |
|
37 | - unset($conditions['page']); |
|
38 | - if (count($conditions)) { |
|
39 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
40 | - $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
41 | - } |
|
42 | - /** |
|
43 | - * Paginate or all data. |
|
44 | - */ |
|
45 | - if ($perPage) { |
|
46 | - return $report->paginate($perPage); |
|
47 | - } else { |
|
48 | - return $report->get(); |
|
49 | - } |
|
50 | - } |
|
21 | + /** |
|
22 | + * Render the given report db view based on the given |
|
23 | + * condition. |
|
24 | + * |
|
25 | + * @param mixed $report |
|
26 | + * @param array $conditions |
|
27 | + * @param integer $perPage |
|
28 | + * @return object |
|
29 | + */ |
|
30 | + public function renderReport($report, $conditions = [], $perPage = 0) |
|
31 | + { |
|
32 | + $report = ! filter_var($report, FILTER_VALIDATE_INT) ? $report : $this->find($report); |
|
33 | + /** |
|
34 | + * Fetch data from the report based on the given conditions. |
|
35 | + */ |
|
36 | + $report = \DB::table($report->view_name); |
|
37 | + unset($conditions['page']); |
|
38 | + if (count($conditions)) { |
|
39 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
40 | + $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
41 | + } |
|
42 | + /** |
|
43 | + * Paginate or all data. |
|
44 | + */ |
|
45 | + if ($perPage) { |
|
46 | + return $report->paginate($perPage); |
|
47 | + } else { |
|
48 | + return $report->get(); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class Register extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'name' => 'nullable|string', |
|
28 | - 'email' => 'required|email|unique:users,email', |
|
29 | - 'password' => 'required|min:6' |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'name' => 'nullable|string', |
|
28 | + 'email' => 'required|email|unique:users,email', |
|
29 | + 'password' => 'required|min:6' |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -6,26 +6,26 @@ |
||
6 | 6 | |
7 | 7 | class AssignRoles extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - return true; |
|
17 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get the validation rules that apply to the request. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function rules() |
|
25 | - { |
|
26 | - return [ |
|
27 | - 'role_ids' => 'required|array', |
|
28 | - 'role_ids.*' => 'required|exists:roles,id' |
|
29 | - ]; |
|
30 | - } |
|
19 | + /** |
|
20 | + * Get the validation rules that apply to the request. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function rules() |
|
25 | + { |
|
26 | + return [ |
|
27 | + 'role_ids' => 'required|array', |
|
28 | + 'role_ids.*' => 'required|exists:roles,id' |
|
29 | + ]; |
|
30 | + } |
|
31 | 31 | } |