@@ -5,8 +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\Functional; |
|
| 9 | - |
|
| 10 | 8 | trait FunctionalTesterActions |
| 11 | 9 | { |
| 12 | 10 | /** |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | $content = Yaml::parse($content); |
| 22 | 22 | |
| 23 | 23 | $modelIndex = 0; |
| 24 | - foreach ($content as $model => $i){ |
|
| 24 | + foreach ($content as $model => $i) { |
|
| 25 | 25 | $i = $this->getResourceParams($model, $i); |
| 26 | - $migrationName = 'Create' . ucwords(str_plural($i['name'])); |
|
| 27 | - $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex , 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table'; |
|
| 26 | + $migrationName = 'Create' . ucwords(str_plural($i['name'])); |
|
| 27 | + $migrationFile = date('Y_m_d_His') . '-' . str_pad($modelIndex, 3, 0, STR_PAD_LEFT) . '_' . snake_case($migrationName) . '_table'; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | $this->call('wn:resource', [ |
@@ -70,34 +70,34 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $i['name'] = snake_case($modelName); |
| 72 | 72 | |
| 73 | - foreach(['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation){ |
|
| 74 | - if(isset($i[$relation])){ |
|
| 73 | + foreach (['hasMany', 'hasOne', 'add', 'belongsTo', 'belongsToMany'] as $relation) { |
|
| 74 | + if (isset($i[$relation])) { |
|
| 75 | 75 | $i[$relation] = $this->convertArray($i[$relation], ' ', ','); |
| 76 | 76 | } else { |
| 77 | 77 | $i[$relation] = false; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if($i['belongsToMany']){ |
|
| 81 | + if ($i['belongsToMany']) { |
|
| 82 | 82 | $relations = $this->getArgumentParser('relations')->parse($i['belongsToMany']); |
| 83 | - foreach ($relations as $relation){ |
|
| 83 | + foreach ($relations as $relation) { |
|
| 84 | 84 | $table = ''; |
| 85 | 85 | |
| 86 | - if(! $relation['model']){ |
|
| 86 | + if (!$relation['model']) { |
|
| 87 | 87 | $table = snake_case($relation['name']); |
| 88 | 88 | } else { |
| 89 | 89 | $names = array_reverse(explode("\\", $relation['model'])); |
| 90 | 90 | $table = snake_case($names[0]); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $tables = [ str_singular($table), $i['name'] ]; |
|
| 93 | + $tables = [str_singular($table), $i['name']]; |
|
| 94 | 94 | sort($tables); |
| 95 | 95 | $this->pivotTables[] = $tables; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $fields = []; |
| 100 | - foreach($i['fields'] as $name => $value) { |
|
| 100 | + foreach ($i['fields'] as $name => $value) { |
|
| 101 | 101 | $value['name'] = $name; |
| 102 | 102 | $fields[] = $this->serializeField($value); |
| 103 | 103 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $string = "{$name};{$schema};{$rules};{$tags}"; |
| 120 | 120 | |
| 121 | - if(isset($field['factory']) && !empty($field['factory'])){ |
|
| 121 | + if (isset($field['factory']) && !empty($field['factory'])) { |
|
| 122 | 122 | $string .= ';' . $field['factory']; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | protected function convertArray($list, $old, $new) |
| 129 | 129 | { |
| 130 | - return implode($new, array_filter(explode($old, $list), function($item){ |
|
| 130 | + return implode($new, array_filter(explode($old, $list), function($item) { |
|
| 131 | 131 | return !empty($item); |
| 132 | 132 | })); |
| 133 | 133 | } |