@@ -183,6 +183,11 @@ |
||
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | + /** |
|
187 | + * @param string $contents |
|
188 | + * |
|
189 | + * @return string |
|
190 | + */ |
|
186 | 191 | protected function replacePlaceholders($contents) |
187 | 192 | { |
188 | 193 | $modelName = \Str::camel($this->container['slug']); |
@@ -10,240 +10,240 @@ |
||
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 | - ]; |
|
67 | - |
|
68 | - /** |
|
69 | - * Create a new command instance. |
|
70 | - * |
|
71 | - * @param Filesystem $files |
|
72 | - * @param RepositoryManager $module |
|
73 | - */ |
|
74 | - public function __construct(Filesystem $files, RepositoryManager $module) |
|
75 | - { |
|
76 | - parent::__construct(); |
|
77 | - |
|
78 | - $this->files = $files; |
|
79 | - $this->module = $module; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Execute the console command. |
|
84 | - * |
|
85 | - * @return mixed |
|
86 | - */ |
|
87 | - public function handle() |
|
88 | - { |
|
89 | - $this->container['slug'] = Str::slug($this->argument('slug')); |
|
90 | - $this->container['name'] = Str::studly($this->container['slug']); |
|
91 | - $this->container['version'] = '1.0'; |
|
92 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
93 | - $this->container['location'] = config('modules.default_location'); |
|
94 | - $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
95 | - $this->container['basename'] = Str::studly($this->container['slug']); |
|
96 | - $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
97 | - |
|
98 | - return $this->generate(); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Generate the module. |
|
103 | - */ |
|
104 | - protected function generate() |
|
105 | - { |
|
106 | - $steps = [ |
|
107 | - 'Generating module...' => 'generateModule', |
|
108 | - 'Optimizing module cache...' => 'optimizeModules', |
|
109 | - 'Generating migrations...' => 'generateMigration', |
|
110 | - ]; |
|
111 | - |
|
112 | - $progress = new ProgressBar($this->output, count($steps)); |
|
113 | - $progress->start(); |
|
114 | - |
|
115 | - foreach ($steps as $message => $function) { |
|
116 | - $progress->setMessage($message); |
|
117 | - |
|
118 | - $this->$function(); |
|
119 | - |
|
120 | - $progress->advance(); |
|
121 | - } |
|
122 | - |
|
123 | - $progress->finish(); |
|
124 | - |
|
125 | - event($this->container['slug'] . '.module.made'); |
|
126 | - |
|
127 | - $this->info("\nModule generated successfully."); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Generate defined module folders. |
|
132 | - */ |
|
133 | - protected function generateModule() |
|
134 | - { |
|
135 | - $location = $this->container['location']; |
|
136 | - $root = module_path(null, '', $location); |
|
137 | - $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
138 | - $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
139 | - |
|
140 | - if (!$this->files->isDirectory($root)) { |
|
141 | - $this->files->makeDirectory($root); |
|
142 | - } |
|
143 | - |
|
144 | - $directory = module_path(null, $this->container['basename'], $location); |
|
145 | - $source = __DIR__ . '/Stubs/Module'; |
|
146 | - |
|
147 | - $this->files->makeDirectory($directory); |
|
148 | - |
|
149 | - $sourceFiles = $this->files->allFiles($source, true); |
|
150 | - |
|
151 | - if (!empty($this->mapping)) { |
|
152 | - $search = array_keys($this->mapping); |
|
153 | - $replace = array_values($this->mapping); |
|
154 | - } |
|
155 | - |
|
156 | - foreach ($sourceFiles as $file) { |
|
157 | - $contents = $this->replacePlaceholders($file->getContents()); |
|
158 | - $subPath = $file->getRelativePathname(); |
|
159 | - |
|
160 | - if (!empty($this->mapping)) { |
|
161 | - $subPath = str_replace($search, $replace, $subPath); |
|
162 | - } |
|
163 | - |
|
164 | - $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 | + ]; |
|
67 | + |
|
68 | + /** |
|
69 | + * Create a new command instance. |
|
70 | + * |
|
71 | + * @param Filesystem $files |
|
72 | + * @param RepositoryManager $module |
|
73 | + */ |
|
74 | + public function __construct(Filesystem $files, RepositoryManager $module) |
|
75 | + { |
|
76 | + parent::__construct(); |
|
77 | + |
|
78 | + $this->files = $files; |
|
79 | + $this->module = $module; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Execute the console command. |
|
84 | + * |
|
85 | + * @return mixed |
|
86 | + */ |
|
87 | + public function handle() |
|
88 | + { |
|
89 | + $this->container['slug'] = Str::slug($this->argument('slug')); |
|
90 | + $this->container['name'] = Str::studly($this->container['slug']); |
|
91 | + $this->container['version'] = '1.0'; |
|
92 | + $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
93 | + $this->container['location'] = config('modules.default_location'); |
|
94 | + $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
95 | + $this->container['basename'] = Str::studly($this->container['slug']); |
|
96 | + $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
97 | + |
|
98 | + return $this->generate(); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Generate the module. |
|
103 | + */ |
|
104 | + protected function generate() |
|
105 | + { |
|
106 | + $steps = [ |
|
107 | + 'Generating module...' => 'generateModule', |
|
108 | + 'Optimizing module cache...' => 'optimizeModules', |
|
109 | + 'Generating migrations...' => 'generateMigration', |
|
110 | + ]; |
|
111 | + |
|
112 | + $progress = new ProgressBar($this->output, count($steps)); |
|
113 | + $progress->start(); |
|
114 | + |
|
115 | + foreach ($steps as $message => $function) { |
|
116 | + $progress->setMessage($message); |
|
117 | + |
|
118 | + $this->$function(); |
|
119 | + |
|
120 | + $progress->advance(); |
|
121 | + } |
|
122 | + |
|
123 | + $progress->finish(); |
|
124 | + |
|
125 | + event($this->container['slug'] . '.module.made'); |
|
126 | + |
|
127 | + $this->info("\nModule generated successfully."); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Generate defined module folders. |
|
132 | + */ |
|
133 | + protected function generateModule() |
|
134 | + { |
|
135 | + $location = $this->container['location']; |
|
136 | + $root = module_path(null, '', $location); |
|
137 | + $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
138 | + $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
139 | + |
|
140 | + if (!$this->files->isDirectory($root)) { |
|
141 | + $this->files->makeDirectory($root); |
|
142 | + } |
|
143 | + |
|
144 | + $directory = module_path(null, $this->container['basename'], $location); |
|
145 | + $source = __DIR__ . '/Stubs/Module'; |
|
146 | + |
|
147 | + $this->files->makeDirectory($directory); |
|
148 | + |
|
149 | + $sourceFiles = $this->files->allFiles($source, true); |
|
150 | + |
|
151 | + if (!empty($this->mapping)) { |
|
152 | + $search = array_keys($this->mapping); |
|
153 | + $replace = array_values($this->mapping); |
|
154 | + } |
|
155 | + |
|
156 | + foreach ($sourceFiles as $file) { |
|
157 | + $contents = $this->replacePlaceholders($file->getContents()); |
|
158 | + $subPath = $file->getRelativePathname(); |
|
159 | + |
|
160 | + if (!empty($this->mapping)) { |
|
161 | + $subPath = str_replace($search, $replace, $subPath); |
|
162 | + } |
|
163 | + |
|
164 | + $filePath = $directory . '/' . $subPath; |
|
165 | 165 | |
166 | - // if the file is module.json, replace it with the custom manifest file name |
|
167 | - if ($file->getFilename() === 'module.json' && $manifest) { |
|
168 | - $filePath = str_replace('module.json', $manifest, $filePath); |
|
169 | - } |
|
166 | + // if the file is module.json, replace it with the custom manifest file name |
|
167 | + if ($file->getFilename() === 'module.json' && $manifest) { |
|
168 | + $filePath = str_replace('module.json', $manifest, $filePath); |
|
169 | + } |
|
170 | 170 | |
171 | - // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
172 | - if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
173 | - $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
174 | - } |
|
175 | - $filePath = $this->replacePlaceholders($filePath); |
|
171 | + // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
172 | + if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
173 | + $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
174 | + } |
|
175 | + $filePath = $this->replacePlaceholders($filePath); |
|
176 | 176 | |
177 | - $dir = dirname($filePath); |
|
177 | + $dir = dirname($filePath); |
|
178 | 178 | |
179 | - if (! $this->files->isDirectory($dir)) { |
|
180 | - $this->files->makeDirectory($dir, 0755, true); |
|
181 | - } |
|
182 | - |
|
183 | - $this->files->put($filePath, $contents); |
|
184 | - } |
|
185 | - } |
|
186 | - |
|
187 | - protected function replacePlaceholders($contents) |
|
188 | - { |
|
189 | - $modelName = \Str::camel($this->container['slug']); |
|
190 | - $modelNameSingular = \Str::singular($modelName); |
|
191 | - |
|
192 | - $find = [ |
|
193 | - 'DummyFactory', |
|
194 | - 'DummyModelName', |
|
195 | - 'DummyModuleSlug', |
|
196 | - 'DummyModule', |
|
197 | - 'DummyModel', |
|
198 | - 'DummyDatabaseSeeder', |
|
199 | - 'DummyTableSeeder', |
|
200 | - 'DummyController', |
|
201 | - 'DummyService', |
|
202 | - 'DummyRepository', |
|
203 | - 'InsertDummy', |
|
204 | - 'UpdateDummy', |
|
205 | - 'DummyResource', |
|
206 | - 'DummyObserver', |
|
207 | - 'DummyTableName', |
|
208 | - 'DummyRoutePrefix', |
|
209 | - ]; |
|
210 | - |
|
211 | - $replace = [ |
|
212 | - ucfirst($modelNameSingular) . 'Factory', |
|
213 | - $modelNameSingular, |
|
214 | - $this->container['slug'], |
|
215 | - ucfirst($modelName), |
|
216 | - ucfirst($modelNameSingular), |
|
217 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
218 | - ucfirst($modelName) . 'TableSeeder', |
|
219 | - ucfirst($modelNameSingular) . 'Controller', |
|
220 | - ucfirst($modelNameSingular) . 'Service', |
|
221 | - ucfirst($modelNameSingular) . 'Repository', |
|
222 | - 'Insert' . ucfirst($modelNameSingular), |
|
223 | - 'Update' . ucfirst($modelNameSingular), |
|
224 | - ucfirst($modelNameSingular), |
|
225 | - ucfirst($modelNameSingular) . 'Observer', |
|
226 | - $modelName, |
|
227 | - $modelName, |
|
228 | - ]; |
|
229 | - |
|
230 | - return str_replace($find, $replace, $contents); |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Reset module cache of enabled and disabled modules. |
|
235 | - */ |
|
236 | - protected function optimizeModules() |
|
237 | - { |
|
238 | - return $this->callSilent('module:optimize'); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Generate table migrations. |
|
243 | - */ |
|
244 | - protected function generateMigration() |
|
245 | - { |
|
246 | - $modelName = $this->container['slug']; |
|
247 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
248 | - } |
|
179 | + if (! $this->files->isDirectory($dir)) { |
|
180 | + $this->files->makeDirectory($dir, 0755, true); |
|
181 | + } |
|
182 | + |
|
183 | + $this->files->put($filePath, $contents); |
|
184 | + } |
|
185 | + } |
|
186 | + |
|
187 | + protected function replacePlaceholders($contents) |
|
188 | + { |
|
189 | + $modelName = \Str::camel($this->container['slug']); |
|
190 | + $modelNameSingular = \Str::singular($modelName); |
|
191 | + |
|
192 | + $find = [ |
|
193 | + 'DummyFactory', |
|
194 | + 'DummyModelName', |
|
195 | + 'DummyModuleSlug', |
|
196 | + 'DummyModule', |
|
197 | + 'DummyModel', |
|
198 | + 'DummyDatabaseSeeder', |
|
199 | + 'DummyTableSeeder', |
|
200 | + 'DummyController', |
|
201 | + 'DummyService', |
|
202 | + 'DummyRepository', |
|
203 | + 'InsertDummy', |
|
204 | + 'UpdateDummy', |
|
205 | + 'DummyResource', |
|
206 | + 'DummyObserver', |
|
207 | + 'DummyTableName', |
|
208 | + 'DummyRoutePrefix', |
|
209 | + ]; |
|
210 | + |
|
211 | + $replace = [ |
|
212 | + ucfirst($modelNameSingular) . 'Factory', |
|
213 | + $modelNameSingular, |
|
214 | + $this->container['slug'], |
|
215 | + ucfirst($modelName), |
|
216 | + ucfirst($modelNameSingular), |
|
217 | + ucfirst($modelName) . 'DatabaseSeeder', |
|
218 | + ucfirst($modelName) . 'TableSeeder', |
|
219 | + ucfirst($modelNameSingular) . 'Controller', |
|
220 | + ucfirst($modelNameSingular) . 'Service', |
|
221 | + ucfirst($modelNameSingular) . 'Repository', |
|
222 | + 'Insert' . ucfirst($modelNameSingular), |
|
223 | + 'Update' . ucfirst($modelNameSingular), |
|
224 | + ucfirst($modelNameSingular), |
|
225 | + ucfirst($modelNameSingular) . 'Observer', |
|
226 | + $modelName, |
|
227 | + $modelName, |
|
228 | + ]; |
|
229 | + |
|
230 | + return str_replace($find, $replace, $contents); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Reset module cache of enabled and disabled modules. |
|
235 | + */ |
|
236 | + protected function optimizeModules() |
|
237 | + { |
|
238 | + return $this->callSilent('module:optimize'); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Generate table migrations. |
|
243 | + */ |
|
244 | + protected function generateMigration() |
|
245 | + { |
|
246 | + $modelName = $this->container['slug']; |
|
247 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
248 | + } |
|
249 | 249 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->container['slug'] = Str::slug($this->argument('slug')); |
90 | 90 | $this->container['name'] = Str::studly($this->container['slug']); |
91 | 91 | $this->container['version'] = '1.0'; |
92 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
92 | + $this->container['description'] = 'This is the description for the '.$this->container['name'].' module.'; |
|
93 | 93 | $this->container['location'] = config('modules.default_location'); |
94 | 94 | $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
95 | 95 | $this->container['basename'] = Str::studly($this->container['slug']); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $progress->finish(); |
124 | 124 | |
125 | - event($this->container['slug'] . '.module.made'); |
|
125 | + event($this->container['slug'].'.module.made'); |
|
126 | 126 | |
127 | 127 | $this->info("\nModule generated successfully."); |
128 | 128 | } |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
138 | 138 | $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
139 | 139 | |
140 | - if (!$this->files->isDirectory($root)) { |
|
140 | + if ( ! $this->files->isDirectory($root)) { |
|
141 | 141 | $this->files->makeDirectory($root); |
142 | 142 | } |
143 | 143 | |
144 | 144 | $directory = module_path(null, $this->container['basename'], $location); |
145 | - $source = __DIR__ . '/Stubs/Module'; |
|
145 | + $source = __DIR__.'/Stubs/Module'; |
|
146 | 146 | |
147 | 147 | $this->files->makeDirectory($directory); |
148 | 148 | |
149 | 149 | $sourceFiles = $this->files->allFiles($source, true); |
150 | 150 | |
151 | - if (!empty($this->mapping)) { |
|
151 | + if ( ! empty($this->mapping)) { |
|
152 | 152 | $search = array_keys($this->mapping); |
153 | 153 | $replace = array_values($this->mapping); |
154 | 154 | } |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | $contents = $this->replacePlaceholders($file->getContents()); |
158 | 158 | $subPath = $file->getRelativePathname(); |
159 | 159 | |
160 | - if (!empty($this->mapping)) { |
|
160 | + if ( ! empty($this->mapping)) { |
|
161 | 161 | $subPath = str_replace($search, $replace, $subPath); |
162 | 162 | } |
163 | 163 | |
164 | - $filePath = $directory . '/' . $subPath; |
|
164 | + $filePath = $directory.'/'.$subPath; |
|
165 | 165 | |
166 | 166 | // if the file is module.json, replace it with the custom manifest file name |
167 | 167 | if ($file->getFilename() === 'module.json' && $manifest) { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $dir = dirname($filePath); |
178 | 178 | |
179 | - if (! $this->files->isDirectory($dir)) { |
|
179 | + if ( ! $this->files->isDirectory($dir)) { |
|
180 | 180 | $this->files->makeDirectory($dir, 0755, true); |
181 | 181 | } |
182 | 182 | |
@@ -209,20 +209,20 @@ discard block |
||
209 | 209 | ]; |
210 | 210 | |
211 | 211 | $replace = [ |
212 | - ucfirst($modelNameSingular) . 'Factory', |
|
212 | + ucfirst($modelNameSingular).'Factory', |
|
213 | 213 | $modelNameSingular, |
214 | 214 | $this->container['slug'], |
215 | 215 | ucfirst($modelName), |
216 | 216 | ucfirst($modelNameSingular), |
217 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
218 | - ucfirst($modelName) . 'TableSeeder', |
|
219 | - ucfirst($modelNameSingular) . 'Controller', |
|
220 | - ucfirst($modelNameSingular) . 'Service', |
|
221 | - ucfirst($modelNameSingular) . 'Repository', |
|
222 | - 'Insert' . ucfirst($modelNameSingular), |
|
223 | - 'Update' . ucfirst($modelNameSingular), |
|
217 | + ucfirst($modelName).'DatabaseSeeder', |
|
218 | + ucfirst($modelName).'TableSeeder', |
|
219 | + ucfirst($modelNameSingular).'Controller', |
|
220 | + ucfirst($modelNameSingular).'Service', |
|
221 | + ucfirst($modelNameSingular).'Repository', |
|
222 | + 'Insert'.ucfirst($modelNameSingular), |
|
223 | + 'Update'.ucfirst($modelNameSingular), |
|
224 | 224 | ucfirst($modelNameSingular), |
225 | - ucfirst($modelNameSingular) . 'Observer', |
|
225 | + ucfirst($modelNameSingular).'Observer', |
|
226 | 226 | $modelName, |
227 | 227 | $modelName, |
228 | 228 | ]; |
@@ -244,6 +244,6 @@ discard block |
||
244 | 244 | protected function generateMigration() |
245 | 245 | { |
246 | 246 | $modelName = $this->container['slug']; |
247 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
247 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_'.$modelName.'_table']); |
|
248 | 248 | } |
249 | 249 | } |
@@ -1,7 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use Illuminate\Http\Request; |
|
4 | - |
|
5 | 3 | /* |
6 | 4 | |-------------------------------------------------------------------------- |
7 | 5 | | API Routes |
@@ -15,11 +15,11 @@ |
||
15 | 15 | |
16 | 16 | Route::group(['prefix' => 'DummyRoutePrefix'], function () { |
17 | 17 | |
18 | - Route::get('/', 'DummyController@index'); |
|
19 | - Route::get('/{id}', 'DummyController@find'); |
|
20 | - Route::post('/', 'DummyController@insert'); |
|
21 | - Route::put('/', 'DummyController@update'); |
|
22 | - Route::delete('/{id}', 'DummyController@delete'); |
|
23 | - Route::get('list/deleted', 'DummyController@deleted'); |
|
24 | - Route::patch('restore/{id}', 'DummyController@restore'); |
|
18 | + Route::get('/', 'DummyController@index'); |
|
19 | + Route::get('/{id}', 'DummyController@find'); |
|
20 | + Route::post('/', 'DummyController@insert'); |
|
21 | + Route::put('/', 'DummyController@update'); |
|
22 | + Route::delete('/{id}', 'DummyController@delete'); |
|
23 | + Route::get('list/deleted', 'DummyController@deleted'); |
|
24 | + Route::patch('restore/{id}', 'DummyController@restore'); |
|
25 | 25 | }); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | -Route::group(['prefix' => 'DummyRoutePrefix'], function () { |
|
16 | +Route::group(['prefix' => 'DummyRoutePrefix'], function() { |
|
17 | 17 | |
18 | 18 | Route::get('/', 'DummyController@index'); |
19 | 19 | Route::get('/{id}', 'DummyController@find'); |
@@ -1,7 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -use Illuminate\Http\Request; |
|
4 | - |
|
5 | 3 | /* |
6 | 4 | |-------------------------------------------------------------------------- |
7 | 5 | | API Routes |
@@ -13,7 +13,7 @@ |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | -Route::group(['prefix' => 'roles'], function () { |
|
16 | +Route::group(['prefix' => 'roles'], function() { |
|
17 | 17 | |
18 | 18 | Route::get('/', 'RoleController@index'); |
19 | 19 | Route::get('/{id}', 'RoleController@find'); |
@@ -15,12 +15,12 @@ |
||
15 | 15 | |
16 | 16 | Route::group(['prefix' => 'roles'], function () { |
17 | 17 | |
18 | - Route::get('/', 'RoleController@index'); |
|
19 | - Route::get('/{id}', 'RoleController@find'); |
|
20 | - Route::post('/', 'RoleController@insert'); |
|
21 | - Route::put('/', 'RoleController@update'); |
|
22 | - Route::delete('/{id}', 'RoleController@delete'); |
|
23 | - Route::get('list/deleted', 'RoleController@deleted'); |
|
24 | - Route::patch('restore/{id}', 'RoleController@restore'); |
|
25 | - Route::post('assign/permissions', 'RoleController@assignPermissions'); |
|
18 | + Route::get('/', 'RoleController@index'); |
|
19 | + Route::get('/{id}', 'RoleController@find'); |
|
20 | + Route::post('/', 'RoleController@insert'); |
|
21 | + Route::put('/', 'RoleController@update'); |
|
22 | + Route::delete('/{id}', 'RoleController@delete'); |
|
23 | + Route::get('list/deleted', 'RoleController@deleted'); |
|
24 | + Route::patch('restore/{id}', 'RoleController@restore'); |
|
25 | + Route::post('assign/permissions', 'RoleController@assignPermissions'); |
|
26 | 26 | }); |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class DummyDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(DummyTableSeeder::class); |
|
18 | - $this->call(AssignRelationsSeeder::class); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(DummyTableSeeder::class); |
|
18 | + $this->call(AssignRelationsSeeder::class); |
|
19 | + } |
|
20 | 20 | } |
@@ -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' => 'find', |
|
32 | - 'model' => 'DummyModelName', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'insert', |
|
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' => 'delete', |
|
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' => 'find', |
|
32 | + 'model' => 'DummyModelName', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'insert', |
|
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' => 'delete', |
|
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 | } |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\DummyModule\DummyModel::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - // Add factory attributes |
|
6 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
7 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
8 | - ]; |
|
4 | + return [ |
|
5 | + // Add factory attributes |
|
6 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
7 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
8 | + ]; |
|
9 | 9 | }); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\DummyModule\DummyModel::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\DummyModule\DummyModel::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | // Add factory attributes |
6 | 6 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ModuleServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Bootstrap the module services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'DummyModuleSlug'); |
|
17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
|
9 | + /** |
|
10 | + * Bootstrap the module services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'DummyModuleSlug'); |
|
17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'DummyModuleSlug'); |
|
18 | 18 | |
19 | - $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
|
20 | - $this->loadFactoriesFrom(module_path('DummyModuleSlug', 'Database/Factories', 'app')); |
|
21 | - } |
|
19 | + $this->loadMigrationsFrom(module_path('DummyModuleSlug', 'Database/Migrations', 'app')); |
|
20 | + $this->loadFactoriesFrom(module_path('DummyModuleSlug', 'Database/Factories', 'app')); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Register the module services. |
|
25 | - * |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public function register() |
|
29 | - { |
|
30 | - $this->app->register(RouteServiceProvider::class); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Register the module services. |
|
25 | + * |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public function register() |
|
29 | + { |
|
30 | + $this->app->register(RouteServiceProvider::class); |
|
31 | + } |
|
32 | 32 | } |
@@ -7,73 +7,73 @@ |
||
7 | 7 | |
8 | 8 | class RouteServiceProvider extends ServiceProvider |
9 | 9 | { |
10 | - /** |
|
11 | - * This namespace is applied to your controller routes. |
|
12 | - * |
|
13 | - * In addition, it is set as the URL generator's root namespace. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $namespace = 'App\Modules\DummyModule\Http\Controllers'; |
|
10 | + /** |
|
11 | + * This namespace is applied to your controller routes. |
|
12 | + * |
|
13 | + * In addition, it is set as the URL generator's root namespace. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $namespace = 'App\Modules\DummyModule\Http\Controllers'; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Define your route model bindings, pattern filters, etc. |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function boot() |
|
25 | - { |
|
26 | - // |
|
19 | + /** |
|
20 | + * Define your route model bindings, pattern filters, etc. |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function boot() |
|
25 | + { |
|
26 | + // |
|
27 | 27 | |
28 | - parent::boot(); |
|
29 | - } |
|
28 | + parent::boot(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Define the routes for the module. |
|
33 | - * |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function map() |
|
37 | - { |
|
38 | - $this->mapWebRoutes(); |
|
31 | + /** |
|
32 | + * Define the routes for the module. |
|
33 | + * |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function map() |
|
37 | + { |
|
38 | + $this->mapWebRoutes(); |
|
39 | 39 | |
40 | - $this->mapApiRoutes(); |
|
40 | + $this->mapApiRoutes(); |
|
41 | 41 | |
42 | - // |
|
43 | - } |
|
42 | + // |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Define the "web" routes for the module. |
|
47 | - * |
|
48 | - * These routes all receive session state, CSRF protection, etc. |
|
49 | - * |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - protected function mapWebRoutes() |
|
53 | - { |
|
54 | - Route::group([ |
|
55 | - 'middleware' => 'web', |
|
56 | - 'namespace' => $this->namespace, |
|
57 | - ], function ($router) { |
|
58 | - require module_path('DummyModuleSlug', 'Routes/web.php', 'app'); |
|
59 | - }); |
|
60 | - } |
|
45 | + /** |
|
46 | + * Define the "web" routes for the module. |
|
47 | + * |
|
48 | + * These routes all receive session state, CSRF protection, etc. |
|
49 | + * |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + protected function mapWebRoutes() |
|
53 | + { |
|
54 | + Route::group([ |
|
55 | + 'middleware' => 'web', |
|
56 | + 'namespace' => $this->namespace, |
|
57 | + ], function ($router) { |
|
58 | + require module_path('DummyModuleSlug', 'Routes/web.php', 'app'); |
|
59 | + }); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Define the "api" routes for the module. |
|
64 | - * |
|
65 | - * These routes are typically stateless. |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - protected function mapApiRoutes() |
|
70 | - { |
|
71 | - Route::group([ |
|
72 | - 'middleware' => 'api', |
|
73 | - 'namespace' => $this->namespace, |
|
74 | - 'prefix' => 'api', |
|
75 | - ], function ($router) { |
|
76 | - require module_path('DummyModuleSlug', 'Routes/api.php', 'app'); |
|
77 | - }); |
|
78 | - } |
|
62 | + /** |
|
63 | + * Define the "api" routes for the module. |
|
64 | + * |
|
65 | + * These routes are typically stateless. |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + protected function mapApiRoutes() |
|
70 | + { |
|
71 | + Route::group([ |
|
72 | + 'middleware' => 'api', |
|
73 | + 'namespace' => $this->namespace, |
|
74 | + 'prefix' => 'api', |
|
75 | + ], function ($router) { |
|
76 | + require module_path('DummyModuleSlug', 'Routes/api.php', 'app'); |
|
77 | + }); |
|
78 | + } |
|
79 | 79 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | Route::group([ |
55 | 55 | 'middleware' => 'web', |
56 | 56 | 'namespace' => $this->namespace, |
57 | - ], function ($router) { |
|
57 | + ], function($router) { |
|
58 | 58 | require module_path('DummyModuleSlug', 'Routes/web.php', 'app'); |
59 | 59 | }); |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'middleware' => 'api', |
73 | 73 | 'namespace' => $this->namespace, |
74 | 74 | 'prefix' => 'api', |
75 | - ], function ($router) { |
|
75 | + ], function($router) { |
|
76 | 76 | require module_path('DummyModuleSlug', 'Routes/api.php', 'app'); |
77 | 77 | }); |
78 | 78 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class DummyObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
13 | - |
|
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
18 | - |
|
19 | - public function creating($model) |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
23 | - |
|
24 | - public function created($model) |
|
25 | - { |
|
26 | - // |
|
27 | - } |
|
28 | - |
|
29 | - public function updating($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
33 | - |
|
34 | - public function updated($model) |
|
35 | - { |
|
36 | - // |
|
37 | - } |
|
38 | - |
|
39 | - public function deleting($model) |
|
40 | - { |
|
41 | - // |
|
42 | - } |
|
43 | - |
|
44 | - public function deleted($model) |
|
45 | - { |
|
46 | - // |
|
47 | - } |
|
48 | - |
|
49 | - public function restoring($model) |
|
50 | - { |
|
51 | - // |
|
52 | - } |
|
53 | - |
|
54 | - public function restored($model) |
|
55 | - { |
|
56 | - // |
|
57 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | + |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | + |
|
19 | + public function creating($model) |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | + |
|
24 | + public function created($model) |
|
25 | + { |
|
26 | + // |
|
27 | + } |
|
28 | + |
|
29 | + public function updating($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | + |
|
34 | + public function updated($model) |
|
35 | + { |
|
36 | + // |
|
37 | + } |
|
38 | + |
|
39 | + public function deleting($model) |
|
40 | + { |
|
41 | + // |
|
42 | + } |
|
43 | + |
|
44 | + public function deleted($model) |
|
45 | + { |
|
46 | + // |
|
47 | + } |
|
48 | + |
|
49 | + public function restoring($model) |
|
50 | + { |
|
51 | + // |
|
52 | + } |
|
53 | + |
|
54 | + public function restored($model) |
|
55 | + { |
|
56 | + // |
|
57 | + } |
|
58 | 58 | } |