@@ -5,7 +5,6 @@ |
||
| 5 | 5 | // You should not change it manually as it will be overwritten on next build |
| 6 | 6 | // @codingStandardsIgnoreFile |
| 7 | 7 | |
| 8 | -use Helper\Acceptance; |
|
| 9 | 8 | use Codeception\Module\Cli; |
| 10 | 9 | use Codeception\Module\Filesystem; |
| 11 | 10 | |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | // @codingStandardsIgnoreFile |
| 7 | 7 | |
| 8 | 8 | use Codeception\Module\Asserts; |
| 9 | -use Helper\Unit; |
|
| 10 | 9 | |
| 11 | 10 | trait UnitTesterActions |
| 12 | 11 | { |
@@ -21,16 +21,25 @@ discard block |
||
| 21 | 21 | $this->argumentFormatLoader = new ArgumentFormatLoader($fs); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param string $name |
|
| 26 | + */ |
|
| 24 | 27 | protected function getTemplate($name) |
| 25 | 28 | { |
| 26 | 29 | return $this->templates->load($name); |
| 27 | 30 | } |
| 28 | 31 | |
| 32 | + /** |
|
| 33 | + * @param string $name |
|
| 34 | + */ |
|
| 29 | 35 | protected function getArgumentParser($name){ |
| 30 | 36 | $format = $this->argumentFormatLoader->load($name); |
| 31 | 37 | return new ArgumentParser($format); |
| 32 | 38 | } |
| 33 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $content |
|
| 42 | + */ |
|
| 34 | 43 | protected function save($content, $path, $name, $force = false) |
| 35 | 44 | { |
| 36 | 45 | if (!$force && $this->fs->exists($path) && $this->input->hasOption('force') && !$this->option('force')) { |
@@ -49,6 +58,9 @@ discard block |
||
| 49 | 58 | } |
| 50 | 59 | } |
| 51 | 60 | |
| 61 | + /** |
|
| 62 | + * @param integer $n |
|
| 63 | + */ |
|
| 52 | 64 | protected function spaces($n) |
| 53 | 65 | { |
| 54 | 66 | return str_repeat(' ', $n); |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | class BaseCommand extends Command { |
| 11 | 11 | |
| 12 | 12 | protected $fs; |
| 13 | - protected $templates; |
|
| 13 | + protected $templates; |
|
| 14 | 14 | |
| 15 | - public function __construct(Filesystem $fs) |
|
| 16 | - { |
|
| 15 | + public function __construct(Filesystem $fs) |
|
| 16 | + { |
|
| 17 | 17 | parent::__construct(); |
| 18 | 18 | |
| 19 | 19 | $this->fs = $fs; |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | return $this->templates->load($name); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function getArgumentParser($name){ |
|
| 29 | + protected function getArgumentParser($name) { |
|
| 30 | 30 | $format = $this->argumentFormatLoader->load($name); |
| 31 | 31 | return new ArgumentParser($format); |
| 32 | 32 | } |
@@ -111,6 +111,9 @@ |
||
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | + /** |
|
| 115 | + * @param string $tag |
|
| 116 | + */ |
|
| 114 | 117 | protected function fieldsHavingTag($tag) |
| 115 | 118 | { |
| 116 | 119 | return array_map(function($field){ |
@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php namespace Wn\Generators\Commands; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -use InvalidArgumentException; |
|
| 5 | - |
|
| 6 | 4 | class ResourceCommand extends BaseCommand { |
| 7 | 5 | |
| 8 | 6 | protected $signature = 'wn:resource |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ]); |
| 62 | 62 | |
| 63 | 63 | // generating REST actions trait if doesn't exist |
| 64 | - if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){ |
|
| 64 | + if (!$this->fs->exists('./app/Http/Controllers/RESTActions.php')) { |
|
| 65 | 65 | $this->call('wn:controller:rest-actions'); |
| 66 | 66 | } |
| 67 | 67 | // generating the controller and routes |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | protected function parseFields() |
| 94 | 94 | { |
| 95 | 95 | $fields = $this->argument('fields'); |
| 96 | - if($this->option('parsed')){ |
|
| 96 | + if ($this->option('parsed')) { |
|
| 97 | 97 | $this->fields = $fields; |
| 98 | 98 | } else { |
| 99 | - if(! $fields){ |
|
| 99 | + if (!$fields) { |
|
| 100 | 100 | $this->fields = []; |
| 101 | 101 | } else { |
| 102 | 102 | $this->fields = $this->getArgumentParser('fields') |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | protected function fieldsHavingTag($tag) |
| 122 | 122 | { |
| 123 | - return array_map(function($field){ |
|
| 123 | + return array_map(function($field) { |
|
| 124 | 124 | return $field['name']; |
| 125 | 125 | }, array_filter($this->fields, function($field) use($tag){ |
| 126 | 126 | return in_array($tag, $field['tags']); |
@@ -129,19 +129,19 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | protected function rules() |
| 131 | 131 | { |
| 132 | - return array_map(function($field){ |
|
| 132 | + return array_map(function($field) { |
|
| 133 | 133 | return [ |
| 134 | 134 | 'name' => $field['name'], |
| 135 | 135 | 'rule' => $field['rules'] |
| 136 | 136 | ]; |
| 137 | - }, array_filter($this->fields, function($field){ |
|
| 137 | + }, array_filter($this->fields, function($field) { |
|
| 138 | 138 | return !empty($field['rules']); |
| 139 | 139 | })); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | protected function schema() |
| 143 | 143 | { |
| 144 | - return array_map(function($field){ |
|
| 144 | + return array_map(function($field) { |
|
| 145 | 145 | return array_merge([[ |
| 146 | 146 | 'name' => $field['name'], |
| 147 | 147 | 'args' => [] |
@@ -152,14 +152,14 @@ discard block |
||
| 152 | 152 | protected function foreignKeys() |
| 153 | 153 | { |
| 154 | 154 | $belongsTo = $this->option('belongs-to'); |
| 155 | - if(! $belongsTo) { |
|
| 155 | + if (!$belongsTo) { |
|
| 156 | 156 | return []; |
| 157 | 157 | } |
| 158 | 158 | $relations = $this->getArgumentParser('relations')->parse($belongsTo); |
| 159 | - return array_map(function($relation){ |
|
| 159 | + return array_map(function($relation) { |
|
| 160 | 160 | $name = $relation['model'] ? $relation['model'] : $relation['name']; |
| 161 | 161 | $index = strrpos($name, "\\"); |
| 162 | - if($index) { |
|
| 162 | + if ($index) { |
|
| 163 | 163 | $name = substr($name, $index + 1); |
| 164 | 164 | } |
| 165 | 165 | return snake_case(str_singular($name)) . '_id'; |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | protected function factoryFields() |
| 182 | 182 | { |
| 183 | - return array_map(function($field){ |
|
| 183 | + return array_map(function($field) { |
|
| 184 | 184 | return [ |
| 185 | 185 | 'name' => $field['name'], |
| 186 | 186 | 'type' => $field['factory'] |
| 187 | 187 | ]; |
| 188 | - }, array_filter($this->fields, function($field){ |
|
| 188 | + }, array_filter($this->fields, function($field) { |
|
| 189 | 189 | return isset($field['factory']) && $field['factory']; |
| 190 | 190 | })); |
| 191 | 191 | } |
@@ -135,6 +135,10 @@ |
||
| 135 | 135 | return $string; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | + /** |
|
| 139 | + * @param string $old |
|
| 140 | + * @param string $new |
|
| 141 | + */ |
|
| 138 | 142 | protected function convertArray($list, $old, $new) |
| 139 | 143 | { |
| 140 | 144 | return implode($new, array_filter(explode($old, $list), function($item){ |
@@ -1,6 +1,5 @@ |
||
| 1 | 1 | <?php namespace Wn\Generators\Commands; |
| 2 | 2 | |
| 3 | -use InvalidArgumentException; |
|
| 4 | 3 | use Symfony\Component\Yaml\Yaml; |
| 5 | 4 | |
| 6 | 5 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | $content = Yaml::parse($content); |
| 25 | 25 | |
| 26 | 26 | $modelIndex = 0; |
| 27 | - foreach ($content as $model => $i){ |
|
| 27 | + foreach ($content as $model => $i) { |
|
| 28 | 28 | $i = $this->getResourceParams($model, $i); |
| 29 | - $migrationName = 'Create' . ucwords(str_plural($i['name'])); |
|
| 30 | - $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex , 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table'; |
|
| 29 | + $migrationName = 'Create' . ucwords(str_plural($i['name'])); |
|
| 30 | + $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex, 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table'; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | $options = [ |
@@ -78,34 +78,34 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $i['name'] = snake_case($modelName); |
| 80 | 80 | |
| 81 | - foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){ |
|
| 82 | - if(isset($i[$relation])){ |
|
| 81 | + foreach (['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation) { |
|
| 82 | + if (isset($i[$relation])) { |
|
| 83 | 83 | $i[$relation] = $this->convertArray($i[$relation], ' ', ','); |
| 84 | 84 | } else { |
| 85 | 85 | $i[$relation] = false; |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if($i['belongsToMany']){ |
|
| 89 | + if ($i['belongsToMany']) { |
|
| 90 | 90 | $relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']); |
| 91 | - foreach ($relations as $relation){ |
|
| 91 | + foreach ($relations as $relation) { |
|
| 92 | 92 | $table = ''; |
| 93 | 93 | |
| 94 | - if(! $relation['model']){ |
|
| 94 | + if (!$relation['model']) { |
|
| 95 | 95 | $table = snake_case($relation['name']); |
| 96 | 96 | } else { |
| 97 | 97 | $names = array_reverse(explode("\\", $relation['model'])); |
| 98 | 98 | $table = snake_case($names[0]); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $tables = [ str_singular($table), $i['name'] ]; |
|
| 101 | + $tables = [str_singular($table), $i['name']]; |
|
| 102 | 102 | sort($tables); |
| 103 | 103 | $this->pivotTables[] = $tables; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $fields = []; |
| 108 | - foreach($i['fields'] as $name => $value) { |
|
| 108 | + foreach ($i['fields'] as $name => $value) { |
|
| 109 | 109 | $value['name'] = $name; |
| 110 | 110 | $fields[] = $this->serializeField($value); |
| 111 | 111 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $string = "{$name};{$schema};{$rules};{$tags}"; |
| 128 | 128 | |
| 129 | - if(isset($field['factory']) && !empty($field['factory'])){ |
|
| 129 | + if (isset($field['factory']) && !empty($field['factory'])) { |
|
| 130 | 130 | $string .= ';' . $field['factory']; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | protected function convertArray($list, $old, $new) |
| 137 | 137 | { |
| 138 | - return implode($new, array_filter(explode($old, $list), function($item){ |
|
| 138 | + return implode($new, array_filter(explode($old, $list), function($item) { |
|
| 139 | 139 | return !empty($item); |
| 140 | 140 | })); |
| 141 | 141 | } |
@@ -19,11 +19,11 @@ |
||
| 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 = __DIR__ . "/../../templates/{$name}.wnt"; |
| 24 | 24 | try { |
| 25 | 25 | $this->loaded[$name] = $this->fs->get($path); |
| 26 | - } catch(\Exception $e) { |
|
| 26 | + } catch (\Exception $e) { |
|
| 27 | 27 | throw new TemplateException("Unable to read the file '{$path}'"); |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -7,27 +7,27 @@ |
||
| 7 | 7 | |
| 8 | 8 | class TemplateLoader { |
| 9 | 9 | |
| 10 | - protected $fs; |
|
| 10 | + protected $fs; |
|
| 11 | 11 | |
| 12 | - protected $loaded; |
|
| 12 | + protected $loaded; |
|
| 13 | 13 | |
| 14 | - public function __construct(Filesystem $fs) |
|
| 15 | - { |
|
| 16 | - $this->fs = $fs; |
|
| 17 | - $this->loaded = []; |
|
| 18 | - } |
|
| 14 | + public function __construct(Filesystem $fs) |
|
| 15 | + { |
|
| 16 | + $this->fs = $fs; |
|
| 17 | + $this->loaded = []; |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function load($name) |
|
| 21 | - { |
|
| 22 | - if(! isset($this->loaded[$name])){ |
|
| 23 | - $path = __DIR__ . "/../../templates/{$name}.wnt"; |
|
| 24 | - try { |
|
| 25 | - $this->loaded[$name] = $this->fs->get($path); |
|
| 26 | - } catch(\Exception $e) { |
|
| 27 | - throw new TemplateException("Unable to read the file '{$path}'"); |
|
| 28 | - } |
|
| 29 | - } |
|
| 30 | - return new Template($this, $this->loaded[$name]); |
|
| 31 | - } |
|
| 20 | + public function load($name) |
|
| 21 | + { |
|
| 22 | + if(! isset($this->loaded[$name])){ |
|
| 23 | + $path = __DIR__ . "/../../templates/{$name}.wnt"; |
|
| 24 | + try { |
|
| 25 | + $this->loaded[$name] = $this->fs->get($path); |
|
| 26 | + } catch(\Exception $e) { |
|
| 27 | + throw new TemplateException("Unable to read the file '{$path}'"); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | + return new Template($this, $this->loaded[$name]); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function with($data = []) |
| 35 | 35 | { |
| 36 | - if($data) |
|
| 36 | + if ($data) |
|
| 37 | 37 | $this->dirty = true; |
| 38 | 38 | foreach ($data as $key => $value) { |
| 39 | 39 | $this->data[$key] = $value; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public function get() |
| 45 | 45 | { |
| 46 | - if($this->dirty){ |
|
| 46 | + if ($this->dirty) { |
|
| 47 | 47 | $this->compile(); |
| 48 | 48 | $this->dirty = false; |
| 49 | 49 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public function compile() |
| 54 | 54 | { |
| 55 | 55 | $this->compiled = $this->text; |
| 56 | - foreach($this->data as $key => $value){ |
|
| 56 | + foreach ($this->data as $key => $value) { |
|
| 57 | 57 | $this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled); |
| 58 | 58 | } |
| 59 | 59 | return $this; |
@@ -33,8 +33,9 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function with($data = []) |
| 35 | 35 | { |
| 36 | - if($data) |
|
| 37 | - $this->dirty = true; |
|
| 36 | + if($data) { |
|
| 37 | + $this->dirty = true; |
|
| 38 | + } |
|
| 38 | 39 | foreach ($data as $key => $value) { |
| 39 | 40 | $this->data[$key] = $value; |
| 40 | 41 | } |
@@ -5,58 +5,58 @@ |
||
| 5 | 5 | |
| 6 | 6 | class Template { |
| 7 | 7 | |
| 8 | - protected $loader; |
|
| 9 | - |
|
| 10 | - protected $text; |
|
| 11 | - |
|
| 12 | - protected $data; |
|
| 13 | - |
|
| 14 | - protected $compiled; |
|
| 15 | - |
|
| 16 | - protected $dirty; |
|
| 17 | - |
|
| 18 | - public function __construct(TemplateLoader $loader, $text) |
|
| 19 | - { |
|
| 20 | - $this->loader = $loader; |
|
| 21 | - $this->text = $text; |
|
| 22 | - $this->compiled = ''; |
|
| 23 | - $this->data = []; |
|
| 24 | - $this->dirty = true; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function clean() |
|
| 28 | - { |
|
| 29 | - $this->data = []; |
|
| 30 | - $this->dirty = false; |
|
| 31 | - return $this; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function with($data = []) |
|
| 35 | - { |
|
| 36 | - if($data) |
|
| 37 | - $this->dirty = true; |
|
| 38 | - foreach ($data as $key => $value) { |
|
| 39 | - $this->data[$key] = $value; |
|
| 40 | - } |
|
| 41 | - return $this; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - public function get() |
|
| 45 | - { |
|
| 46 | - if($this->dirty){ |
|
| 47 | - $this->compile(); |
|
| 48 | - $this->dirty = false; |
|
| 49 | - } |
|
| 50 | - return $this->compiled; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function compile() |
|
| 54 | - { |
|
| 55 | - $this->compiled = $this->text; |
|
| 56 | - foreach($this->data as $key => $value){ |
|
| 57 | - $this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled); |
|
| 58 | - } |
|
| 59 | - return $this; |
|
| 60 | - } |
|
| 8 | + protected $loader; |
|
| 9 | + |
|
| 10 | + protected $text; |
|
| 11 | + |
|
| 12 | + protected $data; |
|
| 13 | + |
|
| 14 | + protected $compiled; |
|
| 15 | + |
|
| 16 | + protected $dirty; |
|
| 17 | + |
|
| 18 | + public function __construct(TemplateLoader $loader, $text) |
|
| 19 | + { |
|
| 20 | + $this->loader = $loader; |
|
| 21 | + $this->text = $text; |
|
| 22 | + $this->compiled = ''; |
|
| 23 | + $this->data = []; |
|
| 24 | + $this->dirty = true; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public function clean() |
|
| 28 | + { |
|
| 29 | + $this->data = []; |
|
| 30 | + $this->dirty = false; |
|
| 31 | + return $this; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function with($data = []) |
|
| 35 | + { |
|
| 36 | + if($data) |
|
| 37 | + $this->dirty = true; |
|
| 38 | + foreach ($data as $key => $value) { |
|
| 39 | + $this->data[$key] = $value; |
|
| 40 | + } |
|
| 41 | + return $this; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + public function get() |
|
| 45 | + { |
|
| 46 | + if($this->dirty){ |
|
| 47 | + $this->compile(); |
|
| 48 | + $this->dirty = false; |
|
| 49 | + } |
|
| 50 | + return $this->compiled; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function compile() |
|
| 54 | + { |
|
| 55 | + $this->compiled = $this->text; |
|
| 56 | + foreach($this->data as $key => $value){ |
|
| 57 | + $this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled); |
|
| 58 | + } |
|
| 59 | + return $this; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class ModelCommand extends BaseCommand { |
| 5 | 5 | |
| 6 | - protected $signature = 'wn:model |
|
| 6 | + protected $signature = 'wn:model |
|
| 7 | 7 | {name : Name of the model.} |
| 8 | 8 | {--fillable= : the fillable fields.} |
| 9 | 9 | {--dates= : date fields.} |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | {--force= : override the existing files} |
| 19 | 19 | '; |
| 20 | 20 | |
| 21 | - protected $description = 'Generates a model class for a RESTfull resource'; |
|
| 21 | + protected $description = 'Generates a model class for a RESTfull resource'; |
|
| 22 | 22 | |
| 23 | 23 | public function handle() |
| 24 | 24 | { |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | protected function getAsArrayFields($arg, $isOption = true) |
| 44 | 44 | { |
| 45 | - $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
|
| 45 | + $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
|
| 46 | 46 | if(is_string($arg)){ |
| 47 | - $arg = explode(',', $arg); |
|
| 47 | + $arg = explode(',', $arg); |
|
| 48 | 48 | } else if(! is_array($arg)) { |
| 49 | 49 | $arg = []; |
| 50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | protected function getNamespace() |
| 57 | 57 | { |
| 58 | - return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path')))); |
|
| 58 | + return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path')))); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | protected function getRelations() |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | protected function getAsArrayFields($arg, $isOption = true) |
| 44 | 44 | { |
| 45 | 45 | $arg = ($isOption) ? $this->option($arg) : $this->argument($arg); |
| 46 | - if(is_string($arg)){ |
|
| 46 | + if (is_string($arg)) { |
|
| 47 | 47 | $arg = explode(',', $arg); |
| 48 | - } else if(! is_array($arg)) { |
|
| 48 | + } else if (!is_array($arg)) { |
|
| 49 | 49 | $arg = []; |
| 50 | 50 | } |
| 51 | - return implode(', ', array_map(function($item){ |
|
| 51 | + return implode(', ', array_map(function($item) { |
|
| 52 | 52 | return '"' . $item . '"'; |
| 53 | 53 | }, $arg)); |
| 54 | 54 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $this->getRelationsByType('belongsToMany', 'belongs-to-many', true) |
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | - if(empty($relations)){ |
|
| 70 | + if (empty($relations)) { |
|
| 71 | 71 | return " // Relationships"; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $relations = []; |
| 80 | 80 | $option = $this->option($option); |
| 81 | - if($option){ |
|
| 81 | + if ($option) { |
|
| 82 | 82 | |
| 83 | 83 | $items = $this->getArgumentParser('relations')->parse($option); |
| 84 | 84 | |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | $template = $this->getTemplate($template); |
| 87 | 87 | foreach ($items as $item) { |
| 88 | 88 | $item['type'] = $type; |
| 89 | - if(! $item['model']){ |
|
| 89 | + if (!$item['model']) { |
|
| 90 | 90 | $item['model'] = $this->getNamespace() . '\\' . ucwords(str_singular($item['name'])); |
| 91 | - } else if(strpos($item['model'], '\\') === false ){ |
|
| 91 | + } else if (strpos($item['model'], '\\') === false) { |
|
| 92 | 92 | $item['model'] = $this->getNamespace() . '\\' . $item['model']; |
| 93 | 93 | } |
| 94 | 94 | $relations[] = $template->with($item)->get(); |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | protected function getRules() |
| 101 | 101 | { |
| 102 | 102 | $rules = $this->option('rules'); |
| 103 | - if(! $rules){ |
|
| 103 | + if (!$rules) { |
|
| 104 | 104 | return " // Validation rules"; |
| 105 | 105 | } |
| 106 | 106 | $items = $rules; |
| 107 | - if(! $this->option('parsed')){ |
|
| 107 | + if (!$this->option('parsed')) { |
|
| 108 | 108 | $items = $this->getArgumentParser('rules')->parse($rules); |
| 109 | 109 | } |
| 110 | 110 | $rules = []; |
@@ -3,10 +3,10 @@ |
||
| 3 | 3 | |
| 4 | 4 | class ControllerRestActionsCommand extends BaseCommand { |
| 5 | 5 | |
| 6 | - protected $signature = 'wn:controller:rest-actions |
|
| 6 | + protected $signature = 'wn:controller:rest-actions |
|
| 7 | 7 | {--force= : override the existing files}'; |
| 8 | 8 | |
| 9 | - protected $description = 'Generates REST actions trait to use into controllers'; |
|
| 9 | + protected $description = 'Generates REST actions trait to use into controllers'; |
|
| 10 | 10 | |
| 11 | 11 | public function handle() |
| 12 | 12 | { |