@@ -23,22 +23,22 @@ |
||
| 23 | 23 | { |
| 24 | 24 | $paths = ServiceProvider::pathsToPublish('Wn\Generators\CommandsServiceProvider'); |
| 25 | 25 | |
| 26 | - foreach($paths as $from => $to){ |
|
| 26 | + foreach ($paths as $from => $to) { |
|
| 27 | 27 | $shortFrom = $this->shortPath($from); |
| 28 | 28 | |
| 29 | - if($this->copyFile($from, $to)) { |
|
| 29 | + if ($this->copyFile($from, $to)) { |
|
| 30 | 30 | $this->info($shortFrom . ' has succesfully been copied to ' . $this->shortPath($to)); |
| 31 | - }else{ |
|
| 31 | + } else { |
|
| 32 | 32 | $this->warn($shortFrom . ' could not be copied. To try and force use the --f option.'); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - private function shortPath($path){ |
|
| 37 | + private function shortPath($path) { |
|
| 38 | 38 | return str_replace(base_path(), '', realpath($path)); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - private function copyFile($from, $to){ |
|
| 41 | + private function copyFile($from, $to) { |
|
| 42 | 42 | if ($this->fs->exists($to) && !$this->option('f')) { |
| 43 | 43 | return false; |
| 44 | 44 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | { |
| 7 | 7 | public function boot() |
| 8 | 8 | { |
| 9 | - $configPath = __DIR__.'/../config/lumen-generators.php'; |
|
| 9 | + $configPath = __DIR__ . '/../config/lumen-generators.php'; |
|
| 10 | 10 | $this->publishes([ |
| 11 | 11 | $configPath => base_path('config/lumen-generators.php'), |
| 12 | 12 | ]); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function register() |
| 16 | 16 | { |
| 17 | - $configPath = __DIR__.'/../config/lumen-generators.php'; |
|
| 17 | + $configPath = __DIR__ . '/../config/lumen-generators.php'; |
|
| 18 | 18 | $this->mergeConfigFrom($configPath, 'lumen-generators'); |
| 19 | 19 | |
| 20 | 20 | $this->registerPublishCommand(); |
@@ -32,92 +32,92 @@ discard block |
||
| 32 | 32 | // registerTestCommand |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - protected function registerPublishCommand(){ |
|
| 36 | - $this->app->singleton('command.wn.publish', function($app){ |
|
| 35 | + protected function registerPublishCommand() { |
|
| 36 | + $this->app->singleton('command.wn.publish', function($app) { |
|
| 37 | 37 | return $app['Wn\Generators\Commands\PublishCommand']; |
| 38 | 38 | }); |
| 39 | 39 | $this->commands('command.wn.publish'); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - protected function registerModelCommand(){ |
|
| 43 | - $this->app->singleton('command.wn.model', function($app){ |
|
| 42 | + protected function registerModelCommand() { |
|
| 43 | + $this->app->singleton('command.wn.model', function($app) { |
|
| 44 | 44 | return $app['Wn\Generators\Commands\ModelCommand']; |
| 45 | 45 | }); |
| 46 | 46 | $this->commands('command.wn.model'); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - protected function registerControllerRestActionsCommand(){ |
|
| 50 | - $this->app->singleton('command.wn.controller.rest-actions', function($app){ |
|
| 49 | + protected function registerControllerRestActionsCommand() { |
|
| 50 | + $this->app->singleton('command.wn.controller.rest-actions', function($app) { |
|
| 51 | 51 | return $app['Wn\Generators\Commands\ControllerRestActionsCommand']; |
| 52 | 52 | }); |
| 53 | 53 | $this->commands('command.wn.controller.rest-actions'); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - protected function registerControllerCommand(){ |
|
| 57 | - $this->app->singleton('command.wn.controller', function($app){ |
|
| 56 | + protected function registerControllerCommand() { |
|
| 57 | + $this->app->singleton('command.wn.controller', function($app) { |
|
| 58 | 58 | return $app['Wn\Generators\Commands\ControllerCommand']; |
| 59 | 59 | }); |
| 60 | 60 | $this->commands('command.wn.controller'); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - protected function registerMigrationCommand(){ |
|
| 64 | - $this->app->singleton('command.wn.migration', function($app){ |
|
| 63 | + protected function registerMigrationCommand() { |
|
| 64 | + $this->app->singleton('command.wn.migration', function($app) { |
|
| 65 | 65 | return $app['Wn\Generators\Commands\MigrationCommand']; |
| 66 | 66 | }); |
| 67 | 67 | $this->commands('command.wn.migration'); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function registerRouteCommand(){ |
|
| 71 | - $this->app->singleton('command.wn.route', function($app){ |
|
| 70 | + protected function registerRouteCommand() { |
|
| 71 | + $this->app->singleton('command.wn.route', function($app) { |
|
| 72 | 72 | return $app['Wn\Generators\Commands\RouteCommand']; |
| 73 | 73 | }); |
| 74 | 74 | $this->commands('command.wn.route'); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - protected function registerTestCommand(){ |
|
| 78 | - $this->app->singleton('command.wn.test', function($app){ |
|
| 77 | + protected function registerTestCommand() { |
|
| 78 | + $this->app->singleton('command.wn.test', function($app) { |
|
| 79 | 79 | return $app['Wn\Generators\Commands\TestCommand']; |
| 80 | 80 | }); |
| 81 | 81 | $this->commands('command.wn.test'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - protected function registerResourceCommand(){ |
|
| 85 | - $this->app->singleton('command.wn.resource', function($app){ |
|
| 84 | + protected function registerResourceCommand() { |
|
| 85 | + $this->app->singleton('command.wn.resource', function($app) { |
|
| 86 | 86 | return $app['Wn\Generators\Commands\ResourceCommand']; |
| 87 | 87 | }); |
| 88 | 88 | $this->commands('command.wn.resource'); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function registerResourcesCommand(){ |
|
| 92 | - $this->app->singleton('command.wn.resources', function($app){ |
|
| 91 | + protected function registerResourcesCommand() { |
|
| 92 | + $this->app->singleton('command.wn.resources', function($app) { |
|
| 93 | 93 | return $app['Wn\Generators\Commands\ResourcesCommand']; |
| 94 | 94 | }); |
| 95 | 95 | $this->commands('command.wn.resources'); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - protected function registerPivotTableCommand(){ |
|
| 99 | - $this->app->singleton('command.wn.pivot-table', function($app){ |
|
| 98 | + protected function registerPivotTableCommand() { |
|
| 99 | + $this->app->singleton('command.wn.pivot-table', function($app) { |
|
| 100 | 100 | return $app['Wn\Generators\Commands\PivotTableCommand']; |
| 101 | 101 | }); |
| 102 | 102 | $this->commands('command.wn.pivot-table'); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - protected function registerFactoryCommand(){ |
|
| 106 | - $this->app->singleton('command.wn.factory', function($app){ |
|
| 105 | + protected function registerFactoryCommand() { |
|
| 106 | + $this->app->singleton('command.wn.factory', function($app) { |
|
| 107 | 107 | return $app['Wn\Generators\Commands\FactoryCommand']; |
| 108 | 108 | }); |
| 109 | 109 | $this->commands('command.wn.factory'); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - protected function registerSeederCommand(){ |
|
| 113 | - $this->app->singleton('command.wn.seeder', function($app){ |
|
| 112 | + protected function registerSeederCommand() { |
|
| 113 | + $this->app->singleton('command.wn.seeder', function($app) { |
|
| 114 | 114 | return $app['Wn\Generators\Commands\SeederCommand']; |
| 115 | 115 | }); |
| 116 | 116 | $this->commands('command.wn.seeder'); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - protected function registerPivotSeederCommand(){ |
|
| 120 | - $this->app->singleton('command.wn.pivot.seeder', function($app){ |
|
| 119 | + protected function registerPivotSeederCommand() { |
|
| 120 | + $this->app->singleton('command.wn.pivot.seeder', function($app) { |
|
| 121 | 121 | return $app['Wn\Generators\Commands\PivotSeederCommand']; |
| 122 | 122 | }); |
| 123 | 123 | $this->commands('command.wn.pivot.seeder'); |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | $rules = $this->getRules(false); |
| 49 | 49 | $fields = []; |
| 50 | 50 | |
| 51 | - foreach($rules as $ruleId => $ruleData){ |
|
| 51 | + foreach ($rules as $ruleId => $ruleData) { |
|
| 52 | 52 | $fieldRules = explode(',', $ruleData['rule']); |
| 53 | 53 | |
| 54 | - foreach($fieldRules as $fieldRule){ |
|
| 55 | - if($fieldRule === $rule || str_contains($fieldRule, $rule)){ |
|
| 54 | + foreach ($fieldRules as $fieldRule) { |
|
| 55 | + if ($fieldRule === $rule || str_contains($fieldRule, $rule)) { |
|
| 56 | 56 | $fields[] = $ruleData['name']; |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - return implode(', ', array_map(function($item){ |
|
| 61 | + return implode(', ', array_map(function($item) { |
|
| 62 | 62 | return '"' . $item . '"'; |
| 63 | 63 | }, $fields)); |
| 64 | 64 | } |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | protected function getAsArrayFields($arg, $isOption = true) |
| 67 | 67 | { |
| 68 | 68 | $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
| 69 | - if(is_string($arg)){ |
|
| 69 | + if (is_string($arg)) { |
|
| 70 | 70 | $arg = explode(',', $arg); |
| 71 | - } else if(! is_array($arg)) { |
|
| 71 | + } else if (!is_array($arg)) { |
|
| 72 | 72 | $arg = []; |
| 73 | 73 | } |
| 74 | - return implode(', ', array_map(function($item){ |
|
| 74 | + return implode(', ', array_map(function($item) { |
|
| 75 | 75 | return '"' . $item . '"'; |
| 76 | 76 | }, $arg)); |
| 77 | 77 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->getRelationsByType('belongsToMany', 'belongs-to-many', true) |
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | - if(empty($relations)){ |
|
| 93 | + if (empty($relations)) { |
|
| 94 | 94 | return " // Relationships"; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $relations = []; |
| 103 | 103 | $option = $this->option($option); |
| 104 | - if($option){ |
|
| 104 | + if ($option) { |
|
| 105 | 105 | |
| 106 | 106 | $items = $this->getArgumentParser('relations')->parse($option); |
| 107 | 107 | |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | $template = $this->getTemplate($template); |
| 110 | 110 | foreach ($items as $item) { |
| 111 | 111 | $item['type'] = $type; |
| 112 | - if(! $item['model']){ |
|
| 112 | + if (!$item['model']) { |
|
| 113 | 113 | $item['model'] = $this->getNamespace() . '\\' . ucwords(str_singular($item['name'])); |
| 114 | - } else if(strpos($item['model'], '\\') === false ){ |
|
| 114 | + } else if (strpos($item['model'], '\\') === false) { |
|
| 115 | 115 | $item['model'] = $this->getNamespace() . '\\' . $item['model']; |
| 116 | 116 | } |
| 117 | 117 | $relations[] = $template->with($item)->get(); |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | protected function getRules($inTemplate = true) |
| 124 | 124 | { |
| 125 | 125 | $rules = $this->option('rules'); |
| 126 | - if(! $rules){ |
|
| 126 | + if (!$rules) { |
|
| 127 | 127 | return " // Validation rules"; |
| 128 | 128 | } |
| 129 | 129 | $items = $rules; |
| 130 | - if(! $this->option('parsed')){ |
|
| 130 | + if (!$this->option('parsed')) { |
|
| 131 | 131 | $items = $this->getArgumentParser('rules')->parse($rules); |
| 132 | 132 | } |
| 133 | 133 | $model = $this->argument('name'); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | foreach ($items as $item) { |
| 137 | 137 | $rules[] = $template->with(array_merge( |
| 138 | 138 | $item, |
| 139 | - [ 'model' => $model ] |
|
| 139 | + ['model' => $model] |
|
| 140 | 140 | ))->get(); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -19,12 +19,12 @@ |
||
| 19 | 19 | |
| 20 | 20 | public function load($name) |
| 21 | 21 | { |
| 22 | - if(! isset($this->loaded[$name])){ |
|
| 22 | + if (!isset($this->loaded[$name])) { |
|
| 23 | 23 | $path = config("lumen-generators.custom_templates.{$name}", __DIR__ . "/../../templates/{$name}.wnt"); |
| 24 | 24 | |
| 25 | 25 | try { |
| 26 | 26 | $this->loaded[$name] = $this->fs->get($path); |
| 27 | - } catch(\Exception $e) { |
|
| 27 | + } catch (\Exception $e) { |
|
| 28 | 28 | throw new TemplateException("Unable to read the file '{$path}'"); |
| 29 | 29 | } |
| 30 | 30 | } |