@@ -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,237 +10,237 @@ |
||
| 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 | - 'Routes' => 'Routes' |
|
| 65 | - ]; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Create a new command instance. |
|
| 69 | - * |
|
| 70 | - * @param Filesystem $files |
|
| 71 | - * @param RepositoryManager $module |
|
| 72 | - */ |
|
| 73 | - public function __construct(Filesystem $files, RepositoryManager $module) |
|
| 74 | - { |
|
| 75 | - parent::__construct(); |
|
| 76 | - |
|
| 77 | - $this->files = $files; |
|
| 78 | - $this->module = $module; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Execute the console command. |
|
| 83 | - * |
|
| 84 | - * @return mixed |
|
| 85 | - */ |
|
| 86 | - public function handle() |
|
| 87 | - { |
|
| 88 | - $this->container['slug'] = Str::slug($this->argument('slug')); |
|
| 89 | - $this->container['name'] = Str::studly($this->container['slug']); |
|
| 90 | - $this->container['version'] = '1.0'; |
|
| 91 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
| 92 | - $this->container['location'] = config('modules.default_location'); |
|
| 93 | - $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
| 94 | - $this->container['basename'] = Str::studly($this->container['slug']); |
|
| 95 | - $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
| 96 | - |
|
| 97 | - return $this->generate(); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Generate the module. |
|
| 102 | - */ |
|
| 103 | - protected function generate() |
|
| 104 | - { |
|
| 105 | - $steps = [ |
|
| 106 | - 'Generating module...' => 'generateModule', |
|
| 107 | - 'Optimizing module cache...' => 'optimizeModules', |
|
| 108 | - 'Generating migrations...' => 'generateMigration', |
|
| 109 | - ]; |
|
| 110 | - |
|
| 111 | - $progress = new ProgressBar($this->output, count($steps)); |
|
| 112 | - $progress->start(); |
|
| 113 | - |
|
| 114 | - foreach ($steps as $message => $function) { |
|
| 115 | - $progress->setMessage($message); |
|
| 116 | - |
|
| 117 | - $this->$function(); |
|
| 118 | - |
|
| 119 | - $progress->advance(); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $progress->finish(); |
|
| 123 | - |
|
| 124 | - event($this->container['slug'] . '.module.made'); |
|
| 125 | - |
|
| 126 | - $this->info("\nModule generated successfully."); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Generate defined module folders. |
|
| 131 | - */ |
|
| 132 | - protected function generateModule() |
|
| 133 | - { |
|
| 134 | - $location = $this->container['location']; |
|
| 135 | - $root = module_path(null, '', $location); |
|
| 136 | - $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
| 137 | - $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
| 138 | - |
|
| 139 | - if (!$this->files->isDirectory($root)) { |
|
| 140 | - $this->files->makeDirectory($root); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $directory = module_path(null, $this->container['basename'], $location); |
|
| 144 | - $source = __DIR__ . '/Stubs/Module'; |
|
| 145 | - |
|
| 146 | - $this->files->makeDirectory($directory); |
|
| 147 | - |
|
| 148 | - $sourceFiles = $this->files->allFiles($source, true); |
|
| 149 | - |
|
| 150 | - if (!empty($this->mapping)) { |
|
| 151 | - $search = array_keys($this->mapping); |
|
| 152 | - $replace = array_values($this->mapping); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - foreach ($sourceFiles as $file) { |
|
| 156 | - $contents = $this->replacePlaceholders($file->getContents()); |
|
| 157 | - $subPath = $file->getRelativePathname(); |
|
| 158 | - |
|
| 159 | - if (!empty($this->mapping)) { |
|
| 160 | - $subPath = str_replace($search, $replace, $subPath); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - $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 | + 'Routes' => 'Routes' |
|
| 65 | + ]; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Create a new command instance. |
|
| 69 | + * |
|
| 70 | + * @param Filesystem $files |
|
| 71 | + * @param RepositoryManager $module |
|
| 72 | + */ |
|
| 73 | + public function __construct(Filesystem $files, RepositoryManager $module) |
|
| 74 | + { |
|
| 75 | + parent::__construct(); |
|
| 76 | + |
|
| 77 | + $this->files = $files; |
|
| 78 | + $this->module = $module; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Execute the console command. |
|
| 83 | + * |
|
| 84 | + * @return mixed |
|
| 85 | + */ |
|
| 86 | + public function handle() |
|
| 87 | + { |
|
| 88 | + $this->container['slug'] = Str::slug($this->argument('slug')); |
|
| 89 | + $this->container['name'] = Str::studly($this->container['slug']); |
|
| 90 | + $this->container['version'] = '1.0'; |
|
| 91 | + $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
| 92 | + $this->container['location'] = config('modules.default_location'); |
|
| 93 | + $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
|
| 94 | + $this->container['basename'] = Str::studly($this->container['slug']); |
|
| 95 | + $this->container['namespace'] = config("modules.locations.{$this->container['location']}.namespace").$this->container['basename']; |
|
| 96 | + |
|
| 97 | + return $this->generate(); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Generate the module. |
|
| 102 | + */ |
|
| 103 | + protected function generate() |
|
| 104 | + { |
|
| 105 | + $steps = [ |
|
| 106 | + 'Generating module...' => 'generateModule', |
|
| 107 | + 'Optimizing module cache...' => 'optimizeModules', |
|
| 108 | + 'Generating migrations...' => 'generateMigration', |
|
| 109 | + ]; |
|
| 110 | + |
|
| 111 | + $progress = new ProgressBar($this->output, count($steps)); |
|
| 112 | + $progress->start(); |
|
| 113 | + |
|
| 114 | + foreach ($steps as $message => $function) { |
|
| 115 | + $progress->setMessage($message); |
|
| 116 | + |
|
| 117 | + $this->$function(); |
|
| 118 | + |
|
| 119 | + $progress->advance(); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $progress->finish(); |
|
| 123 | + |
|
| 124 | + event($this->container['slug'] . '.module.made'); |
|
| 125 | + |
|
| 126 | + $this->info("\nModule generated successfully."); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Generate defined module folders. |
|
| 131 | + */ |
|
| 132 | + protected function generateModule() |
|
| 133 | + { |
|
| 134 | + $location = $this->container['location']; |
|
| 135 | + $root = module_path(null, '', $location); |
|
| 136 | + $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
|
| 137 | + $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
|
| 138 | + |
|
| 139 | + if (!$this->files->isDirectory($root)) { |
|
| 140 | + $this->files->makeDirectory($root); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $directory = module_path(null, $this->container['basename'], $location); |
|
| 144 | + $source = __DIR__ . '/Stubs/Module'; |
|
| 145 | + |
|
| 146 | + $this->files->makeDirectory($directory); |
|
| 147 | + |
|
| 148 | + $sourceFiles = $this->files->allFiles($source, true); |
|
| 149 | + |
|
| 150 | + if (!empty($this->mapping)) { |
|
| 151 | + $search = array_keys($this->mapping); |
|
| 152 | + $replace = array_values($this->mapping); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + foreach ($sourceFiles as $file) { |
|
| 156 | + $contents = $this->replacePlaceholders($file->getContents()); |
|
| 157 | + $subPath = $file->getRelativePathname(); |
|
| 158 | + |
|
| 159 | + if (!empty($this->mapping)) { |
|
| 160 | + $subPath = str_replace($search, $replace, $subPath); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + $filePath = $directory . '/' . $subPath; |
|
| 164 | 164 | |
| 165 | - // if the file is module.json, replace it with the custom manifest file name |
|
| 166 | - if ($file->getFilename() === 'module.json' && $manifest) { |
|
| 167 | - $filePath = str_replace('module.json', $manifest, $filePath); |
|
| 168 | - } |
|
| 165 | + // if the file is module.json, replace it with the custom manifest file name |
|
| 166 | + if ($file->getFilename() === 'module.json' && $manifest) { |
|
| 167 | + $filePath = str_replace('module.json', $manifest, $filePath); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
| 171 | - if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
| 172 | - $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
| 173 | - } |
|
| 174 | - $filePath = $this->replacePlaceholders($filePath); |
|
| 170 | + // if the file is ModuleServiceProvider.php, replace it with the custom provider file name |
|
| 171 | + if ($file->getFilename() === 'ModuleServiceProvider.php') { |
|
| 172 | + $filePath = str_replace('ModuleServiceProvider', $provider, $filePath); |
|
| 173 | + } |
|
| 174 | + $filePath = $this->replacePlaceholders($filePath); |
|
| 175 | 175 | |
| 176 | - $dir = dirname($filePath); |
|
| 176 | + $dir = dirname($filePath); |
|
| 177 | 177 | |
| 178 | - if (! $this->files->isDirectory($dir)) { |
|
| 179 | - $this->files->makeDirectory($dir, 0755, true); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $this->files->put($filePath, $contents); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - protected function replacePlaceholders($contents) |
|
| 187 | - { |
|
| 188 | - $modelName = \Str::camel($this->container['slug']); |
|
| 189 | - $modelNameSingular = \Str::singular($modelName); |
|
| 190 | - |
|
| 191 | - $find = [ |
|
| 192 | - 'DummyFactory', |
|
| 193 | - 'DummyModelName', |
|
| 194 | - 'DummyModuleSlug', |
|
| 195 | - 'DummyModule', |
|
| 196 | - 'DummyModel', |
|
| 197 | - 'DummyDatabaseSeeder', |
|
| 198 | - 'DummyTableSeeder', |
|
| 199 | - 'DummyController', |
|
| 200 | - 'DummyRepository', |
|
| 201 | - 'InsertDummy', |
|
| 202 | - 'UpdateDummy', |
|
| 203 | - 'DummyResource', |
|
| 204 | - 'DummyObserver', |
|
| 205 | - 'DummyTableName', |
|
| 206 | - 'DummyRoutePrefix', |
|
| 207 | - ]; |
|
| 208 | - |
|
| 209 | - $replace = [ |
|
| 210 | - ucfirst($modelNameSingular) . 'Factory', |
|
| 211 | - $modelNameSingular, |
|
| 212 | - $this->container['slug'], |
|
| 213 | - ucfirst($modelName), |
|
| 214 | - ucfirst($modelNameSingular), |
|
| 215 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
| 216 | - ucfirst($modelName) . 'TableSeeder', |
|
| 217 | - ucfirst($modelNameSingular) . 'Controller', |
|
| 218 | - ucfirst($modelNameSingular) . 'Repository', |
|
| 219 | - 'Insert' . ucfirst($modelNameSingular), |
|
| 220 | - 'Update' . ucfirst($modelNameSingular), |
|
| 221 | - ucfirst($modelNameSingular), |
|
| 222 | - ucfirst($modelNameSingular) . 'Observer', |
|
| 223 | - $modelName, |
|
| 224 | - $modelName, |
|
| 225 | - ]; |
|
| 226 | - |
|
| 227 | - return str_replace($find, $replace, $contents); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Reset module cache of enabled and disabled modules. |
|
| 232 | - */ |
|
| 233 | - protected function optimizeModules() |
|
| 234 | - { |
|
| 235 | - return $this->callSilent('module:optimize'); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Generate table migrations. |
|
| 240 | - */ |
|
| 241 | - protected function generateMigration() |
|
| 242 | - { |
|
| 243 | - $modelName = $this->container['slug']; |
|
| 244 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
| 245 | - } |
|
| 178 | + if (! $this->files->isDirectory($dir)) { |
|
| 179 | + $this->files->makeDirectory($dir, 0755, true); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $this->files->put($filePath, $contents); |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + protected function replacePlaceholders($contents) |
|
| 187 | + { |
|
| 188 | + $modelName = \Str::camel($this->container['slug']); |
|
| 189 | + $modelNameSingular = \Str::singular($modelName); |
|
| 190 | + |
|
| 191 | + $find = [ |
|
| 192 | + 'DummyFactory', |
|
| 193 | + 'DummyModelName', |
|
| 194 | + 'DummyModuleSlug', |
|
| 195 | + 'DummyModule', |
|
| 196 | + 'DummyModel', |
|
| 197 | + 'DummyDatabaseSeeder', |
|
| 198 | + 'DummyTableSeeder', |
|
| 199 | + 'DummyController', |
|
| 200 | + 'DummyRepository', |
|
| 201 | + 'InsertDummy', |
|
| 202 | + 'UpdateDummy', |
|
| 203 | + 'DummyResource', |
|
| 204 | + 'DummyObserver', |
|
| 205 | + 'DummyTableName', |
|
| 206 | + 'DummyRoutePrefix', |
|
| 207 | + ]; |
|
| 208 | + |
|
| 209 | + $replace = [ |
|
| 210 | + ucfirst($modelNameSingular) . 'Factory', |
|
| 211 | + $modelNameSingular, |
|
| 212 | + $this->container['slug'], |
|
| 213 | + ucfirst($modelName), |
|
| 214 | + ucfirst($modelNameSingular), |
|
| 215 | + ucfirst($modelName) . 'DatabaseSeeder', |
|
| 216 | + ucfirst($modelName) . 'TableSeeder', |
|
| 217 | + ucfirst($modelNameSingular) . 'Controller', |
|
| 218 | + ucfirst($modelNameSingular) . 'Repository', |
|
| 219 | + 'Insert' . ucfirst($modelNameSingular), |
|
| 220 | + 'Update' . ucfirst($modelNameSingular), |
|
| 221 | + ucfirst($modelNameSingular), |
|
| 222 | + ucfirst($modelNameSingular) . 'Observer', |
|
| 223 | + $modelName, |
|
| 224 | + $modelName, |
|
| 225 | + ]; |
|
| 226 | + |
|
| 227 | + return str_replace($find, $replace, $contents); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Reset module cache of enabled and disabled modules. |
|
| 232 | + */ |
|
| 233 | + protected function optimizeModules() |
|
| 234 | + { |
|
| 235 | + return $this->callSilent('module:optimize'); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Generate table migrations. |
|
| 240 | + */ |
|
| 241 | + protected function generateMigration() |
|
| 242 | + { |
|
| 243 | + $modelName = $this->container['slug']; |
|
| 244 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
| 245 | + } |
|
| 246 | 246 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->container['slug'] = Str::slug($this->argument('slug')); |
| 89 | 89 | $this->container['name'] = Str::studly($this->container['slug']); |
| 90 | 90 | $this->container['version'] = '1.0'; |
| 91 | - $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.'; |
|
| 91 | + $this->container['description'] = 'This is the description for the '.$this->container['name'].' module.'; |
|
| 92 | 92 | $this->container['location'] = config('modules.default_location'); |
| 93 | 93 | $this->container['provider'] = config("modules.locations.{$this->container['location']}.provider"); |
| 94 | 94 | $this->container['basename'] = Str::studly($this->container['slug']); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $progress->finish(); |
| 123 | 123 | |
| 124 | - event($this->container['slug'] . '.module.made'); |
|
| 124 | + event($this->container['slug'].'.module.made'); |
|
| 125 | 125 | |
| 126 | 126 | $this->info("\nModule generated successfully."); |
| 127 | 127 | } |
@@ -136,18 +136,18 @@ discard block |
||
| 136 | 136 | $manifest = config("modules.locations.$location.manifest") ?: 'module.json'; |
| 137 | 137 | $provider = config("modules.locations.$location.provider") ?: 'ModuleServiceProvider'; |
| 138 | 138 | |
| 139 | - if (!$this->files->isDirectory($root)) { |
|
| 139 | + if ( ! $this->files->isDirectory($root)) { |
|
| 140 | 140 | $this->files->makeDirectory($root); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $directory = module_path(null, $this->container['basename'], $location); |
| 144 | - $source = __DIR__ . '/Stubs/Module'; |
|
| 144 | + $source = __DIR__.'/Stubs/Module'; |
|
| 145 | 145 | |
| 146 | 146 | $this->files->makeDirectory($directory); |
| 147 | 147 | |
| 148 | 148 | $sourceFiles = $this->files->allFiles($source, true); |
| 149 | 149 | |
| 150 | - if (!empty($this->mapping)) { |
|
| 150 | + if ( ! empty($this->mapping)) { |
|
| 151 | 151 | $search = array_keys($this->mapping); |
| 152 | 152 | $replace = array_values($this->mapping); |
| 153 | 153 | } |
@@ -156,11 +156,11 @@ discard block |
||
| 156 | 156 | $contents = $this->replacePlaceholders($file->getContents()); |
| 157 | 157 | $subPath = $file->getRelativePathname(); |
| 158 | 158 | |
| 159 | - if (!empty($this->mapping)) { |
|
| 159 | + if ( ! empty($this->mapping)) { |
|
| 160 | 160 | $subPath = str_replace($search, $replace, $subPath); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $filePath = $directory . '/' . $subPath; |
|
| 163 | + $filePath = $directory.'/'.$subPath; |
|
| 164 | 164 | |
| 165 | 165 | // if the file is module.json, replace it with the custom manifest file name |
| 166 | 166 | if ($file->getFilename() === 'module.json' && $manifest) { |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $dir = dirname($filePath); |
| 177 | 177 | |
| 178 | - if (! $this->files->isDirectory($dir)) { |
|
| 178 | + if ( ! $this->files->isDirectory($dir)) { |
|
| 179 | 179 | $this->files->makeDirectory($dir, 0755, true); |
| 180 | 180 | } |
| 181 | 181 | |
@@ -207,19 +207,19 @@ discard block |
||
| 207 | 207 | ]; |
| 208 | 208 | |
| 209 | 209 | $replace = [ |
| 210 | - ucfirst($modelNameSingular) . 'Factory', |
|
| 210 | + ucfirst($modelNameSingular).'Factory', |
|
| 211 | 211 | $modelNameSingular, |
| 212 | 212 | $this->container['slug'], |
| 213 | 213 | ucfirst($modelName), |
| 214 | 214 | ucfirst($modelNameSingular), |
| 215 | - ucfirst($modelName) . 'DatabaseSeeder', |
|
| 216 | - ucfirst($modelName) . 'TableSeeder', |
|
| 217 | - ucfirst($modelNameSingular) . 'Controller', |
|
| 218 | - ucfirst($modelNameSingular) . 'Repository', |
|
| 219 | - 'Insert' . ucfirst($modelNameSingular), |
|
| 220 | - 'Update' . ucfirst($modelNameSingular), |
|
| 215 | + ucfirst($modelName).'DatabaseSeeder', |
|
| 216 | + ucfirst($modelName).'TableSeeder', |
|
| 217 | + ucfirst($modelNameSingular).'Controller', |
|
| 218 | + ucfirst($modelNameSingular).'Repository', |
|
| 219 | + 'Insert'.ucfirst($modelNameSingular), |
|
| 220 | + 'Update'.ucfirst($modelNameSingular), |
|
| 221 | 221 | ucfirst($modelNameSingular), |
| 222 | - ucfirst($modelNameSingular) . 'Observer', |
|
| 222 | + ucfirst($modelNameSingular).'Observer', |
|
| 223 | 223 | $modelName, |
| 224 | 224 | $modelName, |
| 225 | 225 | ]; |
@@ -241,6 +241,6 @@ discard block |
||
| 241 | 241 | protected function generateMigration() |
| 242 | 242 | { |
| 243 | 243 | $modelName = $this->container['slug']; |
| 244 | - return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_' . $modelName . '_table']); |
|
| 244 | + return $this->callSilent('make:module:migration', ['slug' => $modelName, 'name' => 'create_'.$modelName.'_table']); |
|
| 245 | 245 | } |
| 246 | 246 | } |
@@ -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 |
@@ -15,11 +15,11 @@ |
||
| 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'); |
|
| 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 | 25 | }); |
@@ -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'); |
@@ -10,38 +10,38 @@ |
||
| 10 | 10 | |
| 11 | 11 | class Kernel extends ConsoleKernel |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * The Artisan commands provided by your application. |
|
| 15 | - * |
|
| 16 | - * @var array |
|
| 17 | - */ |
|
| 18 | - protected $commands = [ |
|
| 19 | - GenerateDoc::class, |
|
| 20 | - MakeNotificationsCommand::class, |
|
| 21 | - MakeModuleCommand::class |
|
| 22 | - ]; |
|
| 13 | + /** |
|
| 14 | + * The Artisan commands provided by your application. |
|
| 15 | + * |
|
| 16 | + * @var array |
|
| 17 | + */ |
|
| 18 | + protected $commands = [ |
|
| 19 | + GenerateDoc::class, |
|
| 20 | + MakeNotificationsCommand::class, |
|
| 21 | + MakeModuleCommand::class |
|
| 22 | + ]; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Define the application's command schedule. |
|
| 26 | - * |
|
| 27 | - * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - protected function schedule(Schedule $schedule) |
|
| 31 | - { |
|
| 32 | - // $schedule->command('inspire') |
|
| 33 | - // ->hourly(); |
|
| 34 | - } |
|
| 24 | + /** |
|
| 25 | + * Define the application's command schedule. |
|
| 26 | + * |
|
| 27 | + * @param \Illuminate\Console\Scheduling\Schedule $schedule |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + protected function schedule(Schedule $schedule) |
|
| 31 | + { |
|
| 32 | + // $schedule->command('inspire') |
|
| 33 | + // ->hourly(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Register the commands for the application. |
|
| 38 | - * |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - protected function commands() |
|
| 42 | - { |
|
| 43 | - $this->load(__DIR__.'/Commands'); |
|
| 36 | + /** |
|
| 37 | + * Register the commands for the application. |
|
| 38 | + * |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + protected function commands() |
|
| 42 | + { |
|
| 43 | + $this->load(__DIR__.'/Commands'); |
|
| 44 | 44 | |
| 45 | - require base_path('routes/console.php'); |
|
| 46 | - } |
|
| 45 | + require base_path('routes/console.php'); |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -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 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AssignRelationsSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Assign the permissions to the admin group. |
|
| 20 | - */ |
|
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function ($permission) use ($adminGroupId) { |
|
| 22 | - \DB::table('groups_permissions')->insert( |
|
| 23 | - [ |
|
| 24 | - 'permission_id' => $permission->id, |
|
| 25 | - 'group_id' => $adminGroupId, |
|
| 26 | - 'created_at' => \DB::raw('NOW()'), |
|
| 27 | - 'updated_at' => \DB::raw('NOW()') |
|
| 28 | - ] |
|
| 29 | - ); |
|
| 30 | - }); |
|
| 31 | - } |
|
| 18 | + /** |
|
| 19 | + * Assign the permissions to the admin group. |
|
| 20 | + */ |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function ($permission) use ($adminGroupId) { |
|
| 22 | + \DB::table('groups_permissions')->insert( |
|
| 23 | + [ |
|
| 24 | + 'permission_id' => $permission->id, |
|
| 25 | + 'group_id' => $adminGroupId, |
|
| 26 | + 'created_at' => \DB::raw('NOW()'), |
|
| 27 | + 'updated_at' => \DB::raw('NOW()') |
|
| 28 | + ] |
|
| 29 | + ); |
|
| 30 | + }); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | /** |
| 19 | 19 | * Assign the permissions to the admin group. |
| 20 | 20 | */ |
| 21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function ($permission) use ($adminGroupId) { |
|
| 21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['DummyModelName'])->each(function($permission) use ($adminGroupId) { |
|
| 22 | 22 | \DB::table('groups_permissions')->insert( |
| 23 | 23 | [ |
| 24 | 24 | 'permission_id' => $permission->id, |
@@ -6,15 +6,15 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ClearDataSeeder extends Seeder |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the database seeds. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function run() |
|
| 15 | - { |
|
| 16 | - $permissions = \DB::table('permissions')->whereIn('model', ['DummyModelName']); |
|
| 17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | - $permissions->delete(); |
|
| 19 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $permissions = \DB::table('permissions')->whereIn('model', ['DummyModelName']); |
|
| 17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
| 18 | + $permissions->delete(); |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -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'), |