@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | use _generated\FunctionalTesterActions; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Define custom actions here |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * Define custom actions here |
|
| 25 | + */ |
|
| 26 | 26 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | use _generated\UnitTesterActions; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Define custom actions here |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * Define custom actions here |
|
| 25 | + */ |
|
| 26 | 26 | } |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | " public static \$rules = [\n" . |
| 102 | 102 | " \"name\" => \"required\"," . PHP_EOL . |
| 103 | 103 | " \"age\" => \"integer|min:13\"," . PHP_EOL . |
| 104 | -" \"email\" => \"email|unique:users,email_address\",\n". |
|
| 104 | +" \"email\" => \"email|unique:users,email_address\",\n" . |
|
| 105 | 105 | " ];" |
| 106 | 106 | ); |
| 107 | 107 | |
@@ -101,14 +101,14 @@ |
||
| 101 | 101 | $I->seeFileFound('./database/migrations/create_tasks.php'); |
| 102 | 102 | $I->openFile('./database/migrations/create_tasks.php'); |
| 103 | 103 | $I->seeInThisFile( |
| 104 | -"\$table->foreign('category_type_id')\n". |
|
| 105 | -" ->references('id')\n". |
|
| 104 | +"\$table->foreign('category_type_id')\n" . |
|
| 105 | +" ->references('id')\n" . |
|
| 106 | 106 | " ->on('category_types');" |
| 107 | 107 | ); |
| 108 | 108 | $I->seeInThisFile( |
| 109 | -"\$table->foreign('user_id')\n". |
|
| 110 | -" ->references('identifier')\n". |
|
| 111 | -" ->on('members')". PHP_EOL . |
|
| 109 | +"\$table->foreign('user_id')\n" . |
|
| 110 | +" ->references('identifier')\n" . |
|
| 111 | +" ->on('members')" . PHP_EOL . |
|
| 112 | 112 | " ->onDelete('cascade');"); |
| 113 | 113 | $I->deleteFile('./database/migrations/create_tasks.php'); |
| 114 | 114 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -$factory->define(App\User::class, function ($faker) { |
|
| 14 | +$factory->define(App\User::class, function($faker) { |
|
| 15 | 15 | return [ |
| 16 | 16 | 'name' => $faker->name, |
| 17 | 17 | 'email' => $faker->email, |
@@ -5,8 +5,8 @@ |
||
| 5 | 5 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the |
| 6 | 6 | // built-in PHP web server. This provides a convenient way to test a Lumen |
| 7 | 7 | // application without having installed a "real" server software here. |
| 8 | -if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { |
|
| 8 | +if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) { |
|
| 9 | 9 | return false; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -require_once __DIR__.'/public/index.php'; |
|
| 12 | +require_once __DIR__ . '/public/index.php'; |
|
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -$app = require __DIR__.'/../bootstrap/app.php'; |
|
| 14 | +$app = require __DIR__ . '/../bootstrap/app.php'; |
|
| 15 | 15 | |
| 16 | 16 | /* |
| 17 | 17 | |-------------------------------------------------------------------------- |
@@ -3,41 +3,41 @@ |
||
| 3 | 3 | |
| 4 | 4 | class ArgumentFormat { |
| 5 | 5 | |
| 6 | - /** |
|
| 7 | - * Argument name |
|
| 8 | - * |
|
| 9 | - * @var string |
|
| 10 | - */ |
|
| 11 | - public $name; |
|
| 6 | + /** |
|
| 7 | + * Argument name |
|
| 8 | + * |
|
| 9 | + * @var string |
|
| 10 | + */ |
|
| 11 | + public $name; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * One of the types: array, object, string, boolean, number |
|
| 15 | - * |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - public $type; |
|
| 13 | + /** |
|
| 14 | + * One of the types: array, object, string, boolean, number |
|
| 15 | + * |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + public $type; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The default value |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - public $default; |
|
| 20 | + /** |
|
| 21 | + * The default value |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + public $default; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * The separator, by default ":" for object and "," for array. |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - public $separator; |
|
| 27 | + /** |
|
| 28 | + * The separator, by default ":" for object and "," for array. |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + public $separator; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Specify the format of fields for object |
|
| 36 | - * [ field_name => Format, field_name => Format, ... ] |
|
| 37 | - * Specify the format of an element of array |
|
| 38 | - * |
|
| 39 | - * @var mixed |
|
| 40 | - */ |
|
| 41 | - public $format; |
|
| 34 | + /** |
|
| 35 | + * Specify the format of fields for object |
|
| 36 | + * [ field_name => Format, field_name => Format, ... ] |
|
| 37 | + * Specify the format of an element of array |
|
| 38 | + * |
|
| 39 | + * @var mixed |
|
| 40 | + */ |
|
| 41 | + public $format; |
|
| 42 | 42 | |
| 43 | 43 | } |
@@ -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 |
@@ -168,6 +168,9 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | + /** |
|
| 172 | + * @param string $tag |
|
| 173 | + */ |
|
| 171 | 174 | protected function fieldsHavingTag($tag) |
| 172 | 175 | { |
| 173 | 176 | return array_map(function($field){ |
@@ -199,6 +202,9 @@ discard block |
||
| 199 | 202 | }, $this->fields); |
| 200 | 203 | } |
| 201 | 204 | |
| 205 | + /** |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 202 | 208 | protected function getBaseModel($path) { |
| 203 | 209 | $index = strrpos($path, "\\"); |
| 204 | 210 | if($index) { |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | '--parsed' => true |
| 75 | 75 | ]); |
| 76 | 76 | |
| 77 | - if (! $this->option('no-controller')) { |
|
| 77 | + if (!$this->option('no-controller')) { |
|
| 78 | 78 | // generating REST actions trait if doesn't exist |
| 79 | - if(! $this->fs->exists('./app/Http/Controllers/RESTActions.php')){ |
|
| 79 | + if (!$this->fs->exists('./app/Http/Controllers/RESTActions.php')) { |
|
| 80 | 80 | $this->call('wn:controller:rest-actions'); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | // generating model factory |
| 102 | 102 | $this->call('wn:factory', [ |
| 103 | - 'model' => $this->getNamespace().'\\'.$modelName, |
|
| 104 | - '--file' => './database/factories/'.str_plural($modelName).'.php', |
|
| 103 | + 'model' => $this->getNamespace() . '\\' . $modelName, |
|
| 104 | + '--file' => './database/factories/' . str_plural($modelName) . '.php', |
|
| 105 | 105 | '--fields' => $this->factoryFields(), |
| 106 | 106 | '--force' => $this->option('force'), |
| 107 | 107 | '--parsed' => true |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | protected function parseFields() |
| 118 | 118 | { |
| 119 | 119 | $fields = $this->argument('fields'); |
| 120 | - if($this->option('parsed')){ |
|
| 120 | + if ($this->option('parsed')) { |
|
| 121 | 121 | $this->fields = $fields; |
| 122 | 122 | } else { |
| 123 | - if(! $fields){ |
|
| 123 | + if (!$fields) { |
|
| 124 | 124 | $this->fields = []; |
| 125 | 125 | } else { |
| 126 | 126 | $this->fields = $this->getArgumentParser('fields') |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if ($name['nullable']) { |
| 152 | 152 | $return['schema'][] = ['name' => 'nullable', 'args' => []]; |
| 153 | 153 | } else { |
| 154 | - $return['rules'] = 'required'.(!empty($return['rules'])?'|'.$return['rules']:''); |
|
| 154 | + $return['rules'] = 'required' . (!empty($return['rules']) ? '|' . $return['rules'] : ''); |
|
| 155 | 155 | } |
| 156 | 156 | } else { |
| 157 | 157 | $return['schema'] = [ |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | protected function fieldsHavingTag($tag) |
| 172 | 172 | { |
| 173 | - return array_map(function($field){ |
|
| 173 | + return array_map(function($field) { |
|
| 174 | 174 | return $field['name']; |
| 175 | 175 | }, array_filter($this->fields, function($field) use($tag){ |
| 176 | 176 | return in_array($tag, $field['tags']); |
@@ -179,19 +179,19 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | protected function rules() |
| 181 | 181 | { |
| 182 | - return array_map(function($field){ |
|
| 182 | + return array_map(function($field) { |
|
| 183 | 183 | return [ |
| 184 | 184 | 'name' => $field['name'], |
| 185 | 185 | 'rule' => $field['rules'] |
| 186 | 186 | ]; |
| 187 | - }, array_filter($this->fields, function($field){ |
|
| 187 | + }, array_filter($this->fields, function($field) { |
|
| 188 | 188 | return !empty($field['rules']); |
| 189 | 189 | })); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | protected function schema() |
| 193 | 193 | { |
| 194 | - return array_map(function($field){ |
|
| 194 | + return array_map(function($field) { |
|
| 195 | 195 | return array_merge([[ |
| 196 | 196 | 'name' => $field['name'], |
| 197 | 197 | 'args' => [] |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | protected function getBaseModel($path) { |
| 203 | 203 | $index = strrpos($path, "\\"); |
| 204 | - if($index) { |
|
| 204 | + if ($index) { |
|
| 205 | 205 | return substr($path, $index + 1); |
| 206 | 206 | } |
| 207 | 207 | return $path; |
@@ -212,19 +212,19 @@ discard block |
||
| 212 | 212 | $belongsTo = $this->option('belongs-to'); |
| 213 | 213 | $morphTo = $this->option('morph-to'); |
| 214 | 214 | |
| 215 | - if(! $belongsTo && (! $withMorph || ! $morphTo)) { |
|
| 215 | + if (!$belongsTo && (!$withMorph || !$morphTo)) { |
|
| 216 | 216 | return []; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | $belongsTo = $belongsTo ? $this->getArgumentParser('relations')->parse($belongsTo) : []; |
| 220 | 220 | |
| 221 | - $belongsTo = array_map(function($relation){ |
|
| 221 | + $belongsTo = array_map(function($relation) { |
|
| 222 | 222 | return array("model" => camel_case(str_singular($this->getBaseModel($relation['model'] ? $relation['model'] : $relation['name']))), "name" => snake_case(str_singular($this->getBaseModel($relation['name']))) . '_id', "type" => "belongsTo"); |
| 223 | 223 | }, $belongsTo); |
| 224 | 224 | |
| 225 | 225 | if ($withMorph) { |
| 226 | 226 | $morphTo = $morphTo ? $this->getArgumentParser('relations-morphTo')->parse($morphTo) : []; |
| 227 | - $morphTo = array_map(function($relation){ |
|
| 227 | + $morphTo = array_map(function($relation) { |
|
| 228 | 228 | $name = snake_case(str_singular($relation['name'])); |
| 229 | 229 | return array(array("name" => $name . '_id', "type" => "morphTo", "nullable" => $relation['nullable']), array("name" => $name . '_type', "type" => "morphTo", "nullable" => $relation['nullable'])); |
| 230 | 230 | }, $morphTo); |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | protected function factoryFields() |
| 255 | 255 | { |
| 256 | - return array_map(function($field){ |
|
| 256 | + return array_map(function($field) { |
|
| 257 | 257 | return [ |
| 258 | 258 | 'name' => $field['name'], |
| 259 | 259 | 'type' => $field['factory'] |
| 260 | 260 | ]; |
| 261 | - }, array_filter($this->fields, function($field){ |
|
| 261 | + }, array_filter($this->fields, function($field) { |
|
| 262 | 262 | return isset($field['factory']) && $field['factory']; |
| 263 | 263 | })); |
| 264 | 264 | } |