@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Relations Between Models |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -11,43 +11,43 @@ discard block |
||
11 | 11 | | |
12 | 12 | */ |
13 | 13 | |
14 | - 'relations' => [ |
|
15 | - 'user' => [ |
|
16 | - 'index' => [], |
|
17 | - 'show' => [], |
|
18 | - 'account' => [], |
|
19 | - ], |
|
20 | - 'permission' => [ |
|
21 | - 'index' => [], |
|
22 | - 'show' => [], |
|
23 | - ], |
|
24 | - 'role' => [ |
|
25 | - 'index' => [], |
|
26 | - 'show' => [], |
|
27 | - ], |
|
28 | - 'oauthClient' => [ |
|
29 | - 'index' => [], |
|
30 | - 'show' => [], |
|
31 | - ], |
|
32 | - 'notification' => [ |
|
33 | - 'index' => [], |
|
34 | - 'unread' => [], |
|
35 | - ], |
|
36 | - 'pushNotificationDevice' => [ |
|
37 | - 'index' => [], |
|
38 | - 'show' => [], |
|
39 | - ], |
|
40 | - 'report' => [ |
|
41 | - 'index' => [], |
|
42 | - 'show' => [], |
|
43 | - ], |
|
44 | - 'setting' => [ |
|
45 | - 'index' => [], |
|
46 | - 'show' => [], |
|
47 | - ], |
|
48 | - ], |
|
14 | + 'relations' => [ |
|
15 | + 'user' => [ |
|
16 | + 'index' => [], |
|
17 | + 'show' => [], |
|
18 | + 'account' => [], |
|
19 | + ], |
|
20 | + 'permission' => [ |
|
21 | + 'index' => [], |
|
22 | + 'show' => [], |
|
23 | + ], |
|
24 | + 'role' => [ |
|
25 | + 'index' => [], |
|
26 | + 'show' => [], |
|
27 | + ], |
|
28 | + 'oauthClient' => [ |
|
29 | + 'index' => [], |
|
30 | + 'show' => [], |
|
31 | + ], |
|
32 | + 'notification' => [ |
|
33 | + 'index' => [], |
|
34 | + 'unread' => [], |
|
35 | + ], |
|
36 | + 'pushNotificationDevice' => [ |
|
37 | + 'index' => [], |
|
38 | + 'show' => [], |
|
39 | + ], |
|
40 | + 'report' => [ |
|
41 | + 'index' => [], |
|
42 | + 'show' => [], |
|
43 | + ], |
|
44 | + 'setting' => [ |
|
45 | + 'index' => [], |
|
46 | + 'show' => [], |
|
47 | + ], |
|
48 | + ], |
|
49 | 49 | |
50 | - /* |
|
50 | + /* |
|
51 | 51 | |-------------------------------------------------------------------------- |
52 | 52 | | Cache Configurations |
53 | 53 | |-------------------------------------------------------------------------- |
@@ -56,42 +56,42 @@ discard block |
||
56 | 56 | | |
57 | 57 | */ |
58 | 58 | |
59 | - 'cache_config' => [ |
|
60 | - 'oauthClient' => [ |
|
61 | - 'cache' => [ |
|
62 | - 'list', |
|
63 | - 'find', |
|
64 | - 'findBy', |
|
65 | - 'paginate', |
|
66 | - 'paginateBy', |
|
67 | - 'first', |
|
68 | - 'deleted' |
|
69 | - ], |
|
70 | - 'clear' => [ |
|
71 | - 'save' => ['oauthClient'], |
|
72 | - 'delete' => ['oauthClient'], |
|
73 | - 'restore' => ['oauthClient'], |
|
74 | - 'revoke' => ['oauthClient'], |
|
75 | - 'ubRevoke' => ['oauthClient'], |
|
76 | - 'regenerateSecret' => ['oauthClient'], |
|
77 | - ], |
|
78 | - ], |
|
79 | - 'setting' => [ |
|
80 | - 'cache' => [ |
|
81 | - 'list', |
|
82 | - 'find', |
|
83 | - 'findBy', |
|
84 | - 'paginate', |
|
85 | - 'paginateBy', |
|
86 | - 'first', |
|
87 | - 'deleted' |
|
88 | - ], |
|
89 | - 'clear' => [ |
|
90 | - 'save' => ['setting'], |
|
91 | - 'delete' => ['setting'], |
|
92 | - 'restore' => ['setting'], |
|
93 | - 'saveMany' => ['setting'], |
|
94 | - ] |
|
95 | - ] |
|
96 | - ] |
|
59 | + 'cache_config' => [ |
|
60 | + 'oauthClient' => [ |
|
61 | + 'cache' => [ |
|
62 | + 'list', |
|
63 | + 'find', |
|
64 | + 'findBy', |
|
65 | + 'paginate', |
|
66 | + 'paginateBy', |
|
67 | + 'first', |
|
68 | + 'deleted' |
|
69 | + ], |
|
70 | + 'clear' => [ |
|
71 | + 'save' => ['oauthClient'], |
|
72 | + 'delete' => ['oauthClient'], |
|
73 | + 'restore' => ['oauthClient'], |
|
74 | + 'revoke' => ['oauthClient'], |
|
75 | + 'ubRevoke' => ['oauthClient'], |
|
76 | + 'regenerateSecret' => ['oauthClient'], |
|
77 | + ], |
|
78 | + ], |
|
79 | + 'setting' => [ |
|
80 | + 'cache' => [ |
|
81 | + 'list', |
|
82 | + 'find', |
|
83 | + 'findBy', |
|
84 | + 'paginate', |
|
85 | + 'paginateBy', |
|
86 | + 'first', |
|
87 | + 'deleted' |
|
88 | + ], |
|
89 | + 'clear' => [ |
|
90 | + 'save' => ['setting'], |
|
91 | + 'delete' => ['setting'], |
|
92 | + 'restore' => ['setting'], |
|
93 | + 'saveMany' => ['setting'], |
|
94 | + ] |
|
95 | + ] |
|
96 | + ] |
|
97 | 97 | ]; |
@@ -10,243 +10,243 @@ |
||
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 | - ]; |
|
68 | - |
|
69 | - /** |
|
70 | - * Create a new command instance. |
|
71 | - * |
|
72 | - * @param Filesystem $files |
|
73 | - * @param RepositoryManager $module |
|
74 | - */ |
|
75 | - public function __construct(Filesystem $files, RepositoryManager $module) |
|
76 | - { |
|
77 | - parent::__construct(); |
|
78 | - |
|
79 | - $this->files = $files; |
|
80 | - $this->module = $module; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Execute the console command. |
|
85 | - * |
|
86 | - * @return mixed |
|
87 | - */ |
|
88 | - public function handle() |
|
89 | - { |
|
90 | - $this->container['slug'] = Str::slug($this->argument('slug')); |
|
91 | - $this->container['name'] = Str::studly($this->container['slug']); |
|
92 | - $this->container['version'] = '1.0'; |
|
93 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
94 | - $this->container['location'] = config('modules.default_location'); |
|
95 | - $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
96 | - $this->container['basename'] = Str::studly($this->container['slug']); |
|
97 | - $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
98 | - |
|
99 | - return $this->generate(); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Generate the module. |
|
104 | - */ |
|
105 | - protected function generate() |
|
106 | - { |
|
107 | - $steps = [ |
|
108 | - 'Generating module...' => 'generateModule', |
|
109 | - 'Optimizing module cache...' => 'optimizeModules', |
|
110 | - 'Generating migrations...' => 'generateMigration', |
|
111 | - ]; |
|
112 | - |
|
113 | - $progress = new ProgressBar($this->output, count($steps)); |
|
114 | - $progress->start(); |
|
115 | - |
|
116 | - foreach ($steps as $message => $function) { |
|
117 | - $progress->setMessage($message); |
|
118 | - |
|
119 | - $this->$function(); |
|
120 | - |
|
121 | - $progress->advance(); |
|
122 | - } |
|
123 | - |
|
124 | - $progress->finish(); |
|
125 | - |
|
126 | - event($this->container['slug'] . '.module.made'); |
|
127 | - |
|
128 | - $this->info("\nModule generated successfully."); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Generate defined module folders. |
|
133 | - */ |
|
134 | - protected function generateModule() |
|
135 | - { |
|
136 | - $location = $this->container['location']; |
|
137 | - $root = module_path(null, '', $location); |
|
138 | - $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
139 | - $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
140 | - |
|
141 | - if (!$this->files->isDirectory($root)) { |
|
142 | - $this->files->makeDirectory($root); |
|
143 | - } |
|
144 | - |
|
145 | - $directory = module_path(null, $this->container['basename'], $location); |
|
146 | - $source = __DIR__ . '/Stubs/Module'; |
|
147 | - |
|
148 | - $this->files->makeDirectory($directory); |
|
149 | - |
|
150 | - $sourceFiles = $this->files->allFiles($source, true); |
|
151 | - |
|
152 | - if (!empty($this->mapping)) { |
|
153 | - $search = array_keys($this->mapping); |
|
154 | - $replace = array_values($this->mapping); |
|
155 | - } |
|
156 | - |
|
157 | - foreach ($sourceFiles as $file) { |
|
158 | - $contents = $this->replacePlaceholders($file->getContents()); |
|
159 | - $subPath = $file->getRelativePathname(); |
|
160 | - |
|
161 | - if (!empty($this->mapping)) { |
|
162 | - $subPath = str_replace($search, $replace, $subPath); |
|
163 | - } |
|
164 | - |
|
165 | - $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 | + ]; |
|
68 | + |
|
69 | + /** |
|
70 | + * Create a new command instance. |
|
71 | + * |
|
72 | + * @param Filesystem $files |
|
73 | + * @param RepositoryManager $module |
|
74 | + */ |
|
75 | + public function __construct(Filesystem $files, RepositoryManager $module) |
|
76 | + { |
|
77 | + parent::__construct(); |
|
78 | + |
|
79 | + $this->files = $files; |
|
80 | + $this->module = $module; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Execute the console command. |
|
85 | + * |
|
86 | + * @return mixed |
|
87 | + */ |
|
88 | + public function handle() |
|
89 | + { |
|
90 | + $this->container['slug'] = Str::slug($this->argument('slug')); |
|
91 | + $this->container['name'] = Str::studly($this->container['slug']); |
|
92 | + $this->container['version'] = '1.0'; |
|
93 | + $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
94 | + $this->container['location'] = config('modules.default_location'); |
|
95 | + $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
96 | + $this->container['basename'] = Str::studly($this->container['slug']); |
|
97 | + $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
98 | + |
|
99 | + return $this->generate(); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Generate the module. |
|
104 | + */ |
|
105 | + protected function generate() |
|
106 | + { |
|
107 | + $steps = [ |
|
108 | + 'Generating module...' => 'generateModule', |
|
109 | + 'Optimizing module cache...' => 'optimizeModules', |
|
110 | + 'Generating migrations...' => 'generateMigration', |
|
111 | + ]; |
|
112 | + |
|
113 | + $progress = new ProgressBar($this->output, count($steps)); |
|
114 | + $progress->start(); |
|
115 | + |
|
116 | + foreach ($steps as $message => $function) { |
|
117 | + $progress->setMessage($message); |
|
118 | + |
|
119 | + $this->$function(); |
|
120 | + |
|
121 | + $progress->advance(); |
|
122 | + } |
|
123 | + |
|
124 | + $progress->finish(); |
|
125 | + |
|
126 | + event($this->container['slug'] . '.module.made'); |
|
127 | + |
|
128 | + $this->info("\nModule generated successfully."); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Generate defined module folders. |
|
133 | + */ |
|
134 | + protected function generateModule() |
|
135 | + { |
|
136 | + $location = $this->container['location']; |
|
137 | + $root = module_path(null, '', $location); |
|
138 | + $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
139 | + $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
140 | + |
|
141 | + if (!$this->files->isDirectory($root)) { |
|
142 | + $this->files->makeDirectory($root); |
|
143 | + } |
|
144 | + |
|
145 | + $directory = module_path(null, $this->container['basename'], $location); |
|
146 | + $source = __DIR__ . '/Stubs/Module'; |
|
147 | + |
|
148 | + $this->files->makeDirectory($directory); |
|
149 | + |
|
150 | + $sourceFiles = $this->files->allFiles($source, true); |
|
151 | + |
|
152 | + if (!empty($this->mapping)) { |
|
153 | + $search = array_keys($this->mapping); |
|
154 | + $replace = array_values($this->mapping); |
|
155 | + } |
|
156 | + |
|
157 | + foreach ($sourceFiles as $file) { |
|
158 | + $contents = $this->replacePlaceholders($file->getContents()); |
|
159 | + $subPath = $file->getRelativePathname(); |
|
160 | + |
|
161 | + if (!empty($this->mapping)) { |
|
162 | + $subPath = str_replace($search, $replace, $subPath); |
|
163 | + } |
|
164 | + |
|
165 | + $filePath = $directory . '/' . $subPath; |
|
166 | 166 | |
167 | - // if the file is module.json, replace it with the custom manifest file name |
|
168 | - if ($file->getFilename() === 'module.json' && $manifest) { |
|
169 | - $filePath = str_replace('module.json', $manifest, $filePath); |
|
170 | - } |
|
167 | + // if the file is module.json, replace it with the custom manifest file name |
|
168 | + if ($file->getFilename() === 'module.json' && $manifest) { |
|
169 | + $filePath = str_replace('module.json', $manifest, $filePath); |
|
170 | + } |
|
171 | 171 | |
172 | - // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
173 | - if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
174 | - $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
175 | - } |
|
176 | - $filePath = $this->replacePlaceholders($filePath); |
|
172 | + // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
173 | + if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
174 | + $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
175 | + } |
|
176 | + $filePath = $this->replacePlaceholders($filePath); |
|
177 | 177 | |
178 | - $dir = dirname($filePath); |
|
178 | + $dir = dirname($filePath); |
|
179 | 179 | |
180 | - if (! $this->files->isDirectory($dir)) { |
|
181 | - $this->files->makeDirectory($dir, 0755, true); |
|
182 | - } |
|
183 | - |
|
184 | - $this->files->put($filePath, $contents); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - protected function replacePlaceholders($contents) |
|
189 | - { |
|
190 | - $modelName = \Str::camel($this->container['slug']); |
|
191 | - $modelNameSingular = \Str::singular($modelName); |
|
192 | - |
|
193 | - $find = [ |
|
194 | - 'DummyFactory', |
|
195 | - 'DummyModelName', |
|
196 | - 'DummyModuleSlug', |
|
197 | - 'DummyModule', |
|
198 | - 'DummyModel', |
|
199 | - 'DummyDatabaseSeeder', |
|
200 | - 'DummyTableSeeder', |
|
201 | - 'DummyController', |
|
202 | - 'DummyService', |
|
203 | - 'DummyRepository', |
|
204 | - 'DummyErrors', |
|
205 | - 'StoreDummy', |
|
206 | - 'DummyResource', |
|
207 | - 'DummyObserver', |
|
208 | - 'DummyTableName', |
|
209 | - 'DummyRoutePrefix', |
|
210 | - ]; |
|
211 | - |
|
212 | - $replace = [ |
|
213 | - ucfirst($modelNameSingular) . 'Factory', |
|
214 | - $modelNameSingular, |
|
215 | - $this->container['slug'], |
|
216 | - ucfirst($modelName), |
|
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), |
|
225 | - ucfirst($modelNameSingular), |
|
226 | - ucfirst($modelNameSingular) . 'Observer', |
|
227 | - \Str::snake($modelName), |
|
228 | - $modelName, |
|
229 | - ]; |
|
230 | - |
|
231 | - return str_replace($find, $replace, $contents); |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * Reset module cache of enabled and disabled modules. |
|
236 | - */ |
|
237 | - protected function optimizeModules() |
|
238 | - { |
|
239 | - return $this->callSilent('module:optimize'); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * Generate table migrations. |
|
244 | - */ |
|
245 | - protected function generateMigration() |
|
246 | - { |
|
247 | - $modelName = $this->container['slug']; |
|
248 | - $migrationName = \Str::camel($modelName); |
|
249 | - $migrationName = \Str::snake($migrationName); |
|
250 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $migrationName . '_table']); |
|
251 | - } |
|
180 | + if (! $this->files->isDirectory($dir)) { |
|
181 | + $this->files->makeDirectory($dir, 0755, true); |
|
182 | + } |
|
183 | + |
|
184 | + $this->files->put($filePath, $contents); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + protected function replacePlaceholders($contents) |
|
189 | + { |
|
190 | + $modelName = \Str::camel($this->container['slug']); |
|
191 | + $modelNameSingular = \Str::singular($modelName); |
|
192 | + |
|
193 | + $find = [ |
|
194 | + 'DummyFactory', |
|
195 | + 'DummyModelName', |
|
196 | + 'DummyModuleSlug', |
|
197 | + 'DummyModule', |
|
198 | + 'DummyModel', |
|
199 | + 'DummyDatabaseSeeder', |
|
200 | + 'DummyTableSeeder', |
|
201 | + 'DummyController', |
|
202 | + 'DummyService', |
|
203 | + 'DummyRepository', |
|
204 | + 'DummyErrors', |
|
205 | + 'StoreDummy', |
|
206 | + 'DummyResource', |
|
207 | + 'DummyObserver', |
|
208 | + 'DummyTableName', |
|
209 | + 'DummyRoutePrefix', |
|
210 | + ]; |
|
211 | + |
|
212 | + $replace = [ |
|
213 | + ucfirst($modelNameSingular) . 'Factory', |
|
214 | + $modelNameSingular, |
|
215 | + $this->container['slug'], |
|
216 | + ucfirst($modelName), |
|
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), |
|
225 | + ucfirst($modelNameSingular), |
|
226 | + ucfirst($modelNameSingular) . 'Observer', |
|
227 | + \Str::snake($modelName), |
|
228 | + $modelName, |
|
229 | + ]; |
|
230 | + |
|
231 | + return str_replace($find, $replace, $contents); |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Reset module cache of enabled and disabled modules. |
|
236 | + */ |
|
237 | + protected function optimizeModules() |
|
238 | + { |
|
239 | + return $this->callSilent('module:optimize'); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * Generate table migrations. |
|
244 | + */ |
|
245 | + protected function generateMigration() |
|
246 | + { |
|
247 | + $modelName = $this->container['slug']; |
|
248 | + $migrationName = \Str::camel($modelName); |
|
249 | + $migrationName = \Str::snake($migrationName); |
|
250 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $migrationName . '_table']); |
|
251 | + } |
|
252 | 252 | } |
@@ -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 | } |
@@ -8,307 +8,307 @@ |
||
8 | 8 | |
9 | 9 | class GenerateDocCommand extends Command |
10 | 10 | { |
11 | - /** |
|
12 | - * The name and signature of the console command. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $signature = 'doc:generate'; |
|
17 | - |
|
18 | - /** |
|
19 | - * The console command description. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $description = 'Generate api documentation'; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var ReprotService |
|
27 | - */ |
|
28 | - protected $reportService; |
|
29 | - |
|
30 | - /** |
|
31 | - * Init new object. |
|
32 | - * |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - public function __construct(ReportService $reportService) |
|
36 | - { |
|
37 | - $this->reportService = $reportService; |
|
38 | - parent::__construct(); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Execute the console command. |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - public function handle() |
|
47 | - { |
|
48 | - $docData = []; |
|
49 | - $docData['models'] = []; |
|
50 | - $routes = $this->getRoutes(); |
|
51 | - foreach ($routes as $route) { |
|
52 | - if ($route) { |
|
53 | - $actoinArray = explode('@', $route['action']); |
|
54 | - if (Arr::get($actoinArray, 1, false)) { |
|
55 | - $prefix = $route['prefix']; |
|
56 | - $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $prefix))); |
|
57 | - if ($prefix === 'telescope') { |
|
58 | - continue; |
|
59 | - } |
|
60 | - |
|
61 | - $controller = $actoinArray[0]; |
|
62 | - $method = $actoinArray[1]; |
|
63 | - $route['name'] = $method; |
|
64 | - $reflectionClass = new \ReflectionClass($controller); |
|
65 | - $reflectionMethod = $reflectionClass->getMethod($method); |
|
66 | - $classProperties = $reflectionClass->getDefaultProperties(); |
|
67 | - $skipLoginCheck = Arr::get($classProperties, 'skipLoginCheck', false); |
|
68 | - $modelName = explode('\\', $controller); |
|
69 | - $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
70 | - |
|
71 | - $this->processDocBlock($route, $reflectionMethod); |
|
72 | - $this->getHeaders($route, $method, $skipLoginCheck); |
|
73 | - $this->getPostData($route, $reflectionMethod, explode('\\', $reflectionClass->getName())[2], $modelName); |
|
74 | - |
|
75 | - $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']); |
|
76 | - $docData['modules'][$module][] = $route; |
|
77 | - |
|
78 | - $this->getModels($modelName, $docData, $reflectionClass); |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
11 | + /** |
|
12 | + * The name and signature of the console command. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $signature = 'doc:generate'; |
|
17 | + |
|
18 | + /** |
|
19 | + * The console command description. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $description = 'Generate api documentation'; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var ReprotService |
|
27 | + */ |
|
28 | + protected $reportService; |
|
29 | + |
|
30 | + /** |
|
31 | + * Init new object. |
|
32 | + * |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + public function __construct(ReportService $reportService) |
|
36 | + { |
|
37 | + $this->reportService = $reportService; |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Execute the console command. |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + public function handle() |
|
47 | + { |
|
48 | + $docData = []; |
|
49 | + $docData['models'] = []; |
|
50 | + $routes = $this->getRoutes(); |
|
51 | + foreach ($routes as $route) { |
|
52 | + if ($route) { |
|
53 | + $actoinArray = explode('@', $route['action']); |
|
54 | + if (Arr::get($actoinArray, 1, false)) { |
|
55 | + $prefix = $route['prefix']; |
|
56 | + $module = \Str::camel(str_replace('/', '_', str_replace('api', '', $prefix))); |
|
57 | + if ($prefix === 'telescope') { |
|
58 | + continue; |
|
59 | + } |
|
60 | + |
|
61 | + $controller = $actoinArray[0]; |
|
62 | + $method = $actoinArray[1]; |
|
63 | + $route['name'] = $method; |
|
64 | + $reflectionClass = new \ReflectionClass($controller); |
|
65 | + $reflectionMethod = $reflectionClass->getMethod($method); |
|
66 | + $classProperties = $reflectionClass->getDefaultProperties(); |
|
67 | + $skipLoginCheck = Arr::get($classProperties, 'skipLoginCheck', false); |
|
68 | + $modelName = explode('\\', $controller); |
|
69 | + $modelName = lcfirst(str_replace('Controller', '', end($modelName))); |
|
70 | + |
|
71 | + $this->processDocBlock($route, $reflectionMethod); |
|
72 | + $this->getHeaders($route, $method, $skipLoginCheck); |
|
73 | + $this->getPostData($route, $reflectionMethod, explode('\\', $reflectionClass->getName())[2], $modelName); |
|
74 | + |
|
75 | + $route['response'] = $this->getResponseObject($modelName, $route['name'], $route['returnDocBlock']); |
|
76 | + $docData['modules'][$module][] = $route; |
|
77 | + |
|
78 | + $this->getModels($modelName, $docData, $reflectionClass); |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - $docData['errors'] = $this->getErrors(); |
|
84 | - $docData['reports'] = $this->reportService->all(); |
|
85 | - \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Get list of all registered routes. |
|
90 | - * |
|
91 | - * @return collection |
|
92 | - */ |
|
93 | - protected function getRoutes() |
|
94 | - { |
|
95 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
96 | - if (strpos($route->uri(), 'api/') !== false) { |
|
97 | - return [ |
|
98 | - 'method' => $route->methods()[0], |
|
99 | - 'uri' => $route->uri(), |
|
100 | - 'action' => $route->getActionName(), |
|
101 | - 'prefix' => $route->getPrefix() |
|
102 | - ]; |
|
103 | - } |
|
104 | - return false; |
|
105 | - })->all(); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Generate headers for the given route. |
|
110 | - * |
|
111 | - * @param array &$route |
|
112 | - * @param string $method |
|
113 | - * @param array $skipLoginCheck |
|
114 | - * @return void |
|
115 | - */ |
|
116 | - protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
117 | - { |
|
118 | - $route['headers'] = [ |
|
119 | - 'Accept' => 'application/json', |
|
120 | - 'Content-Type' => 'application/json', |
|
121 | - 'Accept-Language' => 'The language of the returned data: ar, en or all.', |
|
122 | - 'time-zone' => 'Your locale time zone', |
|
123 | - ]; |
|
124 | - |
|
125 | - |
|
126 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
127 | - $route['headers']['Authorization'] = 'Bearer {token}'; |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Generate description and params for the given route |
|
133 | - * based on the docblock. |
|
134 | - * |
|
135 | - * @param array &$route |
|
136 | - * @param \ReflectionMethod $reflectionMethod |
|
137 | - * @return void |
|
138 | - */ |
|
139 | - protected function processDocBlock(&$route, $reflectionMethod) |
|
140 | - { |
|
141 | - $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
142 | - $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
143 | - $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
144 | - $params = $docblock->getTagsByName('param'); |
|
145 | - $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
146 | - |
|
147 | - foreach ($params as $param) { |
|
148 | - $name = $param->getVariableName(); |
|
149 | - if ($name == 'perPage') { |
|
150 | - $route['parametars'][$name] = 'perPage? number of records per page default 15'; |
|
151 | - } elseif ($name == 'sortBy') { |
|
152 | - $route['parametars'][$name] = 'sortBy? sort column default created_at'; |
|
153 | - } elseif ($name == 'desc') { |
|
154 | - $route['parametars'][$name] = 'desc? sort descending or ascending default is descending'; |
|
155 | - } elseif ($name !== 'request') { |
|
156 | - $route['parametars'][$name] = $param->getDescription()->render(); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - if ($route['name'] === 'index') { |
|
161 | - $route['parametars']['perPage'] = 'perPage? number of records per page default 15'; |
|
162 | - $route['parametars']['sortBy'] = 'sortBy? sort column default created_at'; |
|
163 | - $route['parametars']['desc'] = 'desc? sort descending or ascending default is descending'; |
|
164 | - $route['parametars']['trashed'] = 'trashed? retreive trashed or not default not'; |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Generate post body for the given route. |
|
170 | - * |
|
171 | - * @param array &$route |
|
172 | - * @param \ReflectionMethod $reflectionMethod |
|
173 | - * @param string $module |
|
174 | - * @param string $modelName |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - protected function getPostData(&$route, $reflectionMethod, $module, $modelName) |
|
178 | - { |
|
179 | - $parameters = $reflectionMethod->getParameters(); |
|
180 | - $className = optional(optional(\Arr::get($parameters, 0))->getType())->getName(); |
|
181 | - if ($className) { |
|
182 | - $reflectionClass = new \ReflectionClass($className); |
|
183 | - } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) { |
|
184 | - $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store' . ucfirst($modelName); |
|
185 | - $reflectionClass = new \ReflectionClass($className); |
|
186 | - } |
|
187 | - |
|
188 | - if (isset($reflectionClass) && $reflectionClass->hasMethod('rules')) { |
|
189 | - $reflectionMethod = $reflectionClass->getMethod('rules'); |
|
190 | - $route['body'] = $reflectionMethod->invoke(new $className); |
|
191 | - |
|
192 | - foreach ($route['body'] as &$rule) { |
|
193 | - if (strpos($rule, 'unique')) { |
|
194 | - $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
195 | - } elseif (strpos($rule, 'exists')) { |
|
196 | - $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Generate application errors. |
|
204 | - * |
|
205 | - * @return array |
|
206 | - */ |
|
207 | - protected function getErrors() |
|
208 | - { |
|
209 | - $errors = []; |
|
210 | - foreach (\Module::all() as $module) { |
|
211 | - $nameSpace = 'App\\Modules\\' . $module['basename']; |
|
212 | - $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
213 | - $reflectionClass = new \ReflectionClass($class); |
|
214 | - foreach ($reflectionClass->getMethods() as $method) { |
|
215 | - $methodName = $method->name; |
|
216 | - $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
217 | - $body = $this->getMethodBody($reflectionMethod); |
|
218 | - |
|
219 | - preg_match('/abort\(([^#]+)\,/iU', $body, $match); |
|
220 | - |
|
221 | - if (count($match)) { |
|
222 | - $errors[$match[1]][] = $methodName; |
|
223 | - } |
|
224 | - } |
|
225 | - } |
|
226 | - |
|
227 | - return $errors; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Get the given method body code. |
|
232 | - * |
|
233 | - * @param object $reflectionMethod |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - protected function getMethodBody($reflectionMethod) |
|
237 | - { |
|
238 | - $filename = $reflectionMethod->getFileName(); |
|
239 | - $start_line = $reflectionMethod->getStartLine() - 1; |
|
240 | - $end_line = $reflectionMethod->getEndLine(); |
|
241 | - $length = $end_line - $start_line; |
|
242 | - $source = file($filename); |
|
243 | - $body = implode("", array_slice($source, $start_line, $length)); |
|
244 | - $body = trim(preg_replace('/\s+/', '', $body)); |
|
245 | - |
|
246 | - return $body; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Get example object of all availble models. |
|
251 | - * |
|
252 | - * @param string $modelName |
|
253 | - * @param array $docData |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - protected function getModels($modelName, &$docData, $reflectionClass) |
|
257 | - { |
|
258 | - if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
|
259 | - $repo = call_user_func_array("\Core::{$modelName}", []); |
|
260 | - if (! $repo) { |
|
261 | - return; |
|
262 | - } |
|
83 | + $docData['errors'] = $this->getErrors(); |
|
84 | + $docData['reports'] = $this->reportService->all(); |
|
85 | + \File::put(app_path('Modules/Core/Resources/api.json'), json_encode($docData)); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Get list of all registered routes. |
|
90 | + * |
|
91 | + * @return collection |
|
92 | + */ |
|
93 | + protected function getRoutes() |
|
94 | + { |
|
95 | + return collect(\Route::getRoutes())->map(function ($route) { |
|
96 | + if (strpos($route->uri(), 'api/') !== false) { |
|
97 | + return [ |
|
98 | + 'method' => $route->methods()[0], |
|
99 | + 'uri' => $route->uri(), |
|
100 | + 'action' => $route->getActionName(), |
|
101 | + 'prefix' => $route->getPrefix() |
|
102 | + ]; |
|
103 | + } |
|
104 | + return false; |
|
105 | + })->all(); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Generate headers for the given route. |
|
110 | + * |
|
111 | + * @param array &$route |
|
112 | + * @param string $method |
|
113 | + * @param array $skipLoginCheck |
|
114 | + * @return void |
|
115 | + */ |
|
116 | + protected function getHeaders(&$route, $method, $skipLoginCheck) |
|
117 | + { |
|
118 | + $route['headers'] = [ |
|
119 | + 'Accept' => 'application/json', |
|
120 | + 'Content-Type' => 'application/json', |
|
121 | + 'Accept-Language' => 'The language of the returned data: ar, en or all.', |
|
122 | + 'time-zone' => 'Your locale time zone', |
|
123 | + ]; |
|
124 | + |
|
125 | + |
|
126 | + if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
127 | + $route['headers']['Authorization'] = 'Bearer {token}'; |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Generate description and params for the given route |
|
133 | + * based on the docblock. |
|
134 | + * |
|
135 | + * @param array &$route |
|
136 | + * @param \ReflectionMethod $reflectionMethod |
|
137 | + * @return void |
|
138 | + */ |
|
139 | + protected function processDocBlock(&$route, $reflectionMethod) |
|
140 | + { |
|
141 | + $factory = \phpDocumentor\Reflection\DocBlockFactory::createInstance(); |
|
142 | + $docblock = $factory->create($reflectionMethod->getDocComment()); |
|
143 | + $route['description'] = trim(preg_replace('/\s+/', ' ', $docblock->getSummary())); |
|
144 | + $params = $docblock->getTagsByName('param'); |
|
145 | + $route['returnDocBlock'] = $docblock->getTagsByName('return')[0]->getType()->getFqsen()->getName(); |
|
146 | + |
|
147 | + foreach ($params as $param) { |
|
148 | + $name = $param->getVariableName(); |
|
149 | + if ($name == 'perPage') { |
|
150 | + $route['parametars'][$name] = 'perPage? number of records per page default 15'; |
|
151 | + } elseif ($name == 'sortBy') { |
|
152 | + $route['parametars'][$name] = 'sortBy? sort column default created_at'; |
|
153 | + } elseif ($name == 'desc') { |
|
154 | + $route['parametars'][$name] = 'desc? sort descending or ascending default is descending'; |
|
155 | + } elseif ($name !== 'request') { |
|
156 | + $route['parametars'][$name] = $param->getDescription()->render(); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + if ($route['name'] === 'index') { |
|
161 | + $route['parametars']['perPage'] = 'perPage? number of records per page default 15'; |
|
162 | + $route['parametars']['sortBy'] = 'sortBy? sort column default created_at'; |
|
163 | + $route['parametars']['desc'] = 'desc? sort descending or ascending default is descending'; |
|
164 | + $route['parametars']['trashed'] = 'trashed? retreive trashed or not default not'; |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Generate post body for the given route. |
|
170 | + * |
|
171 | + * @param array &$route |
|
172 | + * @param \ReflectionMethod $reflectionMethod |
|
173 | + * @param string $module |
|
174 | + * @param string $modelName |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + protected function getPostData(&$route, $reflectionMethod, $module, $modelName) |
|
178 | + { |
|
179 | + $parameters = $reflectionMethod->getParameters(); |
|
180 | + $className = optional(optional(\Arr::get($parameters, 0))->getType())->getName(); |
|
181 | + if ($className) { |
|
182 | + $reflectionClass = new \ReflectionClass($className); |
|
183 | + } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) { |
|
184 | + $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store' . ucfirst($modelName); |
|
185 | + $reflectionClass = new \ReflectionClass($className); |
|
186 | + } |
|
187 | + |
|
188 | + if (isset($reflectionClass) && $reflectionClass->hasMethod('rules')) { |
|
189 | + $reflectionMethod = $reflectionClass->getMethod('rules'); |
|
190 | + $route['body'] = $reflectionMethod->invoke(new $className); |
|
191 | + |
|
192 | + foreach ($route['body'] as &$rule) { |
|
193 | + if (strpos($rule, 'unique')) { |
|
194 | + $rule = substr($rule, 0, strpos($rule, 'unique') + 6); |
|
195 | + } elseif (strpos($rule, 'exists')) { |
|
196 | + $rule = substr($rule, 0, strpos($rule, 'exists') - 1); |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Generate application errors. |
|
204 | + * |
|
205 | + * @return array |
|
206 | + */ |
|
207 | + protected function getErrors() |
|
208 | + { |
|
209 | + $errors = []; |
|
210 | + foreach (\Module::all() as $module) { |
|
211 | + $nameSpace = 'App\\Modules\\' . $module['basename']; |
|
212 | + $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
213 | + $reflectionClass = new \ReflectionClass($class); |
|
214 | + foreach ($reflectionClass->getMethods() as $method) { |
|
215 | + $methodName = $method->name; |
|
216 | + $reflectionMethod = $reflectionClass->getMethod($methodName); |
|
217 | + $body = $this->getMethodBody($reflectionMethod); |
|
218 | + |
|
219 | + preg_match('/abort\(([^#]+)\,/iU', $body, $match); |
|
220 | + |
|
221 | + if (count($match)) { |
|
222 | + $errors[$match[1]][] = $methodName; |
|
223 | + } |
|
224 | + } |
|
225 | + } |
|
226 | + |
|
227 | + return $errors; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Get the given method body code. |
|
232 | + * |
|
233 | + * @param object $reflectionMethod |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + protected function getMethodBody($reflectionMethod) |
|
237 | + { |
|
238 | + $filename = $reflectionMethod->getFileName(); |
|
239 | + $start_line = $reflectionMethod->getStartLine() - 1; |
|
240 | + $end_line = $reflectionMethod->getEndLine(); |
|
241 | + $length = $end_line - $start_line; |
|
242 | + $source = file($filename); |
|
243 | + $body = implode("", array_slice($source, $start_line, $length)); |
|
244 | + $body = trim(preg_replace('/\s+/', '', $body)); |
|
245 | + |
|
246 | + return $body; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Get example object of all availble models. |
|
251 | + * |
|
252 | + * @param string $modelName |
|
253 | + * @param array $docData |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + protected function getModels($modelName, &$docData, $reflectionClass) |
|
257 | + { |
|
258 | + if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
|
259 | + $repo = call_user_func_array("\Core::{$modelName}", []); |
|
260 | + if (! $repo) { |
|
261 | + return; |
|
262 | + } |
|
263 | 263 | |
264 | - $modelClass = get_class($repo->model); |
|
265 | - $model = factory($modelClass)->make(); |
|
266 | - |
|
267 | - $property = $reflectionClass->getProperty('modelResource'); |
|
268 | - $property->setAccessible(true); |
|
269 | - $modelResource = $property->getValue(\App::make($reflectionClass->getName())); |
|
270 | - |
|
271 | - $relations = []; |
|
272 | - $relationMethods = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphToMany', 'morphTo']; |
|
273 | - $reflector = new \ReflectionClass($model); |
|
274 | - foreach ($reflector->getMethods() as $reflectionMethod) { |
|
275 | - $body = $this->getMethodBody($reflectionMethod); |
|
276 | - foreach ($relationMethods as $relationMethod) { |
|
277 | - $relation = $reflectionMethod->getName(); |
|
278 | - if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') { |
|
279 | - $relations[] = $relation; |
|
280 | - break; |
|
281 | - } |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - $modelResource = new $modelResource($model->load($relations)); |
|
286 | - $modelArr = $modelResource->toArray([]); |
|
287 | - |
|
288 | - foreach ($modelArr as $key => $attr) { |
|
289 | - if (is_object($attr) && property_exists($attr, 'resource') && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) { |
|
290 | - unset($modelArr[$key]); |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Get the route response object type. |
|
300 | - * |
|
301 | - * @param string $modelName |
|
302 | - * @param string $method |
|
303 | - * @param string $returnDocBlock |
|
304 | - * @return array |
|
305 | - */ |
|
306 | - protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
307 | - { |
|
308 | - $relations = config('core.relations'); |
|
309 | - $relations = Arr::has($relations, $modelName) ? Arr::has($relations[$modelName], $method) ? $relations[$modelName] : false : false; |
|
310 | - $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
311 | - |
|
312 | - return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
313 | - } |
|
264 | + $modelClass = get_class($repo->model); |
|
265 | + $model = factory($modelClass)->make(); |
|
266 | + |
|
267 | + $property = $reflectionClass->getProperty('modelResource'); |
|
268 | + $property->setAccessible(true); |
|
269 | + $modelResource = $property->getValue(\App::make($reflectionClass->getName())); |
|
270 | + |
|
271 | + $relations = []; |
|
272 | + $relationMethods = ['hasOne', 'hasMany', 'belongsTo', 'belongsToMany', 'morphToMany', 'morphTo']; |
|
273 | + $reflector = new \ReflectionClass($model); |
|
274 | + foreach ($reflector->getMethods() as $reflectionMethod) { |
|
275 | + $body = $this->getMethodBody($reflectionMethod); |
|
276 | + foreach ($relationMethods as $relationMethod) { |
|
277 | + $relation = $reflectionMethod->getName(); |
|
278 | + if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') { |
|
279 | + $relations[] = $relation; |
|
280 | + break; |
|
281 | + } |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + $modelResource = new $modelResource($model->load($relations)); |
|
286 | + $modelArr = $modelResource->toArray([]); |
|
287 | + |
|
288 | + foreach ($modelArr as $key => $attr) { |
|
289 | + if (is_object($attr) && property_exists($attr, 'resource') && $attr->resource instanceof \Illuminate\Http\Resources\MissingValue) { |
|
290 | + unset($modelArr[$key]); |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + $docData['models'][$modelName] = json_encode($modelArr, JSON_PRETTY_PRINT); |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Get the route response object type. |
|
300 | + * |
|
301 | + * @param string $modelName |
|
302 | + * @param string $method |
|
303 | + * @param string $returnDocBlock |
|
304 | + * @return array |
|
305 | + */ |
|
306 | + protected function getResponseObject($modelName, $method, $returnDocBlock) |
|
307 | + { |
|
308 | + $relations = config('core.relations'); |
|
309 | + $relations = Arr::has($relations, $modelName) ? Arr::has($relations[$modelName], $method) ? $relations[$modelName] : false : false; |
|
310 | + $modelName = call_user_func_array("\Core::{$returnDocBlock}", []) ? $returnDocBlock : $modelName; |
|
311 | + |
|
312 | + return $relations ? [$modelName => $relations && $relations[$method] ? $relations[$method] : []] : false; |
|
313 | + } |
|
314 | 314 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function getRoutes() |
94 | 94 | { |
95 | - return collect(\Route::getRoutes())->map(function ($route) { |
|
95 | + return collect(\Route::getRoutes())->map(function($route) { |
|
96 | 96 | if (strpos($route->uri(), 'api/') !== false) { |
97 | 97 | return [ |
98 | 98 | 'method' => $route->methods()[0], |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ]; |
124 | 124 | |
125 | 125 | |
126 | - if (! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
126 | + if ( ! $skipLoginCheck || ! in_array($method, $skipLoginCheck)) { |
|
127 | 127 | $route['headers']['Authorization'] = 'Bearer {token}'; |
128 | 128 | } |
129 | 129 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if ($className) { |
182 | 182 | $reflectionClass = new \ReflectionClass($className); |
183 | 183 | } elseif (in_array($reflectionMethod->getName(), ['store', 'update'])) { |
184 | - $className = 'App\\Modules\\' . ucfirst($module) . '\\Http\\Requests\\Store' . ucfirst($modelName); |
|
184 | + $className = 'App\\Modules\\'.ucfirst($module).'\\Http\\Requests\\Store'.ucfirst($modelName); |
|
185 | 185 | $reflectionClass = new \ReflectionClass($className); |
186 | 186 | } |
187 | 187 | |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | { |
209 | 209 | $errors = []; |
210 | 210 | foreach (\Module::all() as $module) { |
211 | - $nameSpace = 'App\\Modules\\' . $module['basename']; |
|
212 | - $class = $nameSpace . '\\Errors\\' . $module['basename'] . 'Errors'; |
|
211 | + $nameSpace = 'App\\Modules\\'.$module['basename']; |
|
212 | + $class = $nameSpace.'\\Errors\\'.$module['basename'].'Errors'; |
|
213 | 213 | $reflectionClass = new \ReflectionClass($class); |
214 | 214 | foreach ($reflectionClass->getMethods() as $method) { |
215 | 215 | $methodName = $method->name; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | { |
258 | 258 | if ($modelName && ! Arr::has($docData['models'], $modelName)) { |
259 | 259 | $repo = call_user_func_array("\Core::{$modelName}", []); |
260 | - if (! $repo) { |
|
260 | + if ( ! $repo) { |
|
261 | 261 | return; |
262 | 262 | } |
263 | 263 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $body = $this->getMethodBody($reflectionMethod); |
276 | 276 | foreach ($relationMethods as $relationMethod) { |
277 | 277 | $relation = $reflectionMethod->getName(); |
278 | - if (strpos($body, '$this->' . $relationMethod) && $relation !== 'morphedByMany') { |
|
278 | + if (strpos($body, '$this->'.$relationMethod) && $relation !== 'morphedByMany') { |
|
279 | 279 | $relations[] = $relation; |
280 | 280 | break; |
281 | 281 | } |
@@ -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 | } |
@@ -6,41 +6,41 @@ |
||
6 | 6 | |
7 | 7 | class ApiSkeletonServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->publishes([ |
|
17 | - __DIR__.'/Modules' => app_path('Modules'), |
|
18 | - __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | - __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | - __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | - __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | - __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | - __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | - __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | - __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | - __DIR__.'/../files/Jenkinsfile' => base_path('/Jenkinsfile'), |
|
27 | - __DIR__.'/../files/phpcs.xml' => base_path('/phpcs.xml'), |
|
28 | - __DIR__.'/../files/docker' => base_path('/docker'), |
|
29 | - __DIR__.'/../files/.dockerignore' => base_path('/.dockerignore'), |
|
30 | - ]); |
|
9 | + /** |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->publishes([ |
|
17 | + __DIR__.'/Modules' => app_path('Modules'), |
|
18 | + __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | + __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | + __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | + __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | + __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | + __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | + __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | + __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | + __DIR__.'/../files/Jenkinsfile' => base_path('/Jenkinsfile'), |
|
27 | + __DIR__.'/../files/phpcs.xml' => base_path('/phpcs.xml'), |
|
28 | + __DIR__.'/../files/docker' => base_path('/docker'), |
|
29 | + __DIR__.'/../files/.dockerignore' => base_path('/.dockerignore'), |
|
30 | + ]); |
|
31 | 31 | |
32 | - $this->publishes([ |
|
33 | - __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
34 | - ], 'config'); |
|
35 | - } |
|
32 | + $this->publishes([ |
|
33 | + __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
34 | + ], 'config'); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Register any package services. |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function register() |
|
43 | - { |
|
44 | - // |
|
45 | - } |
|
37 | + /** |
|
38 | + * Register any package services. |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function register() |
|
43 | + { |
|
44 | + // |
|
45 | + } |
|
46 | 46 | } |