@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | private function getWizardAlterInstance($group) |
48 | 48 | { |
49 | - $this->setAlterType('group',$group); |
|
49 | + $this->setAlterType('group', $group); |
|
50 | 50 | |
51 | 51 | return new WizardAlter($this); |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function dropWizardAlterInstance($group) |
59 | 59 | { |
60 | - $this->setAlterType('group',$group); |
|
60 | + $this->setAlterType('group', $group); |
|
61 | 61 | |
62 | 62 | return $this; |
63 | 63 | } |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function addColumn($alterType) |
34 | 34 | { |
35 | - if(isset($alterType['place'])){ |
|
35 | + if (isset($alterType['place'])) { |
|
36 | 36 | |
37 | 37 | |
38 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
39 | - $placeList=$placeKey .' '.$placeValue.''; |
|
38 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
39 | + $placeList = $placeKey.' '.$placeValue.''; |
|
40 | 40 | } |
41 | 41 | |
42 | - $syntax = implode("",$this->syntax); |
|
42 | + $syntax = implode("", $this->syntax); |
|
43 | 43 | |
44 | 44 | $alterSytanx = 'ALTER TABLE '.$this->table.' ADD COLUMN '.$syntax.' '.$placeList; |
45 | 45 | |
46 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
46 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
47 | 47 | |
48 | - if(count($this->alterExtras)){ |
|
49 | - foreach($this->alterExtras as $extra){ |
|
48 | + if (count($this->alterExtras)) { |
|
49 | + foreach ($this->alterExtras as $extra) { |
|
50 | 50 | |
51 | 51 | $extraSyntax = 'ALTER TABLE '.$this->table.' '.$extra.''; |
52 | 52 | |
53 | - $query=$this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
53 | + $query = $this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -74,40 +74,40 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function change($alterType) |
76 | 76 | { |
77 | - if(isset($alterType['place'])){ |
|
77 | + if (isset($alterType['place'])) { |
|
78 | 78 | |
79 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
80 | - $placeList=$placeKey .' '.$placeValue.''; |
|
79 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
80 | + $placeList = $placeKey.' '.$placeValue.''; |
|
81 | 81 | } |
82 | 82 | |
83 | - $syntax = implode("",$this->syntax); |
|
83 | + $syntax = implode("", $this->syntax); |
|
84 | 84 | |
85 | 85 | $columns = $this->schema->getConnection()->showColumnsFrom($this->table); |
86 | 86 | |
87 | - foreach ($columns as $columnKey=>$columnData){ |
|
88 | - if($columnData['Field']==$placeValue){ |
|
87 | + foreach ($columns as $columnKey=>$columnData) { |
|
88 | + if ($columnData['Field']==$placeValue) { |
|
89 | 89 | $changeAbleField = $columns[$columnKey+1]['Field']; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $syntaxList = explode(' ',$syntax); |
|
93 | + $syntaxList = explode(' ', $syntax); |
|
94 | 94 | |
95 | - if(current($syntaxList)!==$changeAbleField){ |
|
96 | - $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
|
95 | + if (current($syntaxList)!==$changeAbleField) { |
|
96 | + $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ', array_splice($syntaxList, 1)).' '.$placeList; |
|
97 | 97 | } |
98 | - else{ |
|
98 | + else { |
|
99 | 99 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
103 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
104 | 104 | |
105 | - if(count($this->alterExtras)){ |
|
106 | - foreach($this->alterExtras as $extra){ |
|
105 | + if (count($this->alterExtras)) { |
|
106 | + foreach ($this->alterExtras as $extra) { |
|
107 | 107 | |
108 | 108 | $extraSyntax = 'ALTER TABLE '.$this->table.' '.$extra.''; |
109 | 109 | |
110 | - $query=$this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
110 | + $query = $this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | */ |
130 | 130 | private function dropColumn($alterType) |
131 | 131 | { |
132 | - if(isset($this->syntax[0])){ |
|
132 | + if (isset($this->syntax[0])) { |
|
133 | 133 | |
134 | 134 | $column = rtrim($this->syntax[0]); |
135 | 135 | |
136 | 136 | $alterSytanx = 'alter table '.$this->table.' drop column '.$column; |
137 | 137 | |
138 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
138 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
139 | 139 | |
140 | 140 | return [ |
141 | 141 | 'syntax'=>$this->syntax, |
@@ -162,32 +162,32 @@ discard block |
||
162 | 162 | |
163 | 163 | $this->getDefaultSyntaxGroup(); |
164 | 164 | |
165 | - $this->syntax[]=')'; |
|
165 | + $this->syntax[] = ')'; |
|
166 | 166 | |
167 | 167 | //get table collation |
168 | - if(isset($this->data['tableCollation']['table'])){ |
|
169 | - $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
168 | + if (isset($this->data['tableCollation']['table'])) { |
|
169 | + $this->syntax[] = ' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
170 | 170 | } |
171 | - else{ |
|
172 | - $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
|
171 | + else { |
|
172 | + $this->syntax[] = ' DEFAULT CHARACTER SET utf8'; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | //get engine |
176 | - if($this->data['engine']!==null) |
|
176 | + if ($this->data['engine']!==null) |
|
177 | 177 | { |
178 | - $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
|
178 | + $this->syntax[] = ' ENGINE='.$this->data['engine'].' '; |
|
179 | 179 | } |
180 | - else{ |
|
181 | - $this->syntax[]=' ENGINE=InnoDB '; |
|
180 | + else { |
|
181 | + $this->syntax[] = ' ENGINE=InnoDB '; |
|
182 | 182 | } |
183 | 183 | |
184 | - $syntax = implode("",$this->syntax); |
|
184 | + $syntax = implode("", $this->syntax); |
|
185 | 185 | |
186 | - if(in_array($this->table,$existTables)){ |
|
186 | + if (in_array($this->table, $existTables)) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | - else{ |
|
190 | - $query=$this->schema->getConnection()->setQueryBasic($syntax); |
|
189 | + else { |
|
190 | + $query = $this->schema->getConnection()->setQueryBasic($syntax); |
|
191 | 191 | |
192 | 192 | return [ |
193 | 193 | 'syntax'=>$syntax, |
@@ -202,41 +202,41 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @param null $group |
204 | 204 | */ |
205 | - private function getDefaultSyntaxGroup($group=null) |
|
205 | + private function getDefaultSyntaxGroup($group = null) |
|
206 | 206 | { |
207 | - $this->syntax[]=implode(",",$this->getCreateDefaultList()); |
|
207 | + $this->syntax[] = implode(",", $this->getCreateDefaultList()); |
|
208 | 208 | |
209 | 209 | //get unique values |
210 | - if(isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])){ |
|
210 | + if (isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])) { |
|
211 | 211 | |
212 | - if($group=='create'){ |
|
213 | - $this->syntax[]=','.implode(',',$this->data['uniqueValueList']); |
|
212 | + if ($group=='create') { |
|
213 | + $this->syntax[] = ','.implode(',', $this->data['uniqueValueList']); |
|
214 | 214 | } |
215 | - else{ |
|
216 | - $this->alterExtras[]='ADD '.implode(',',$this->data['uniqueValueList']); |
|
215 | + else { |
|
216 | + $this->alterExtras[] = 'ADD '.implode(',', $this->data['uniqueValueList']); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | } |
220 | 220 | |
221 | 221 | //get index values |
222 | - if(isset($this->data['indexValueList']) && count($this->data['indexValueList'])){ |
|
222 | + if (isset($this->data['indexValueList']) && count($this->data['indexValueList'])) { |
|
223 | 223 | |
224 | - if($group=='create'){ |
|
225 | - $this->syntax[]=','.implode(',',$this->data['indexValueList']); |
|
224 | + if ($group=='create') { |
|
225 | + $this->syntax[] = ','.implode(',', $this->data['indexValueList']); |
|
226 | 226 | } |
227 | - else{ |
|
228 | - $this->alterExtras[]='ADD '.implode(',',$this->data['indexValueList']); |
|
227 | + else { |
|
228 | + $this->alterExtras[] = 'ADD '.implode(',', $this->data['indexValueList']); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | } |
232 | 232 | |
233 | 233 | //get index values for key |
234 | - if(count($this->getKeyList())){ |
|
235 | - $this->syntax[]=','.implode(',',$this->getKeyList()); |
|
234 | + if (count($this->getKeyList())) { |
|
235 | + $this->syntax[] = ','.implode(',', $this->getKeyList()); |
|
236 | 236 | } |
237 | 237 | |
238 | - if(count($this->data['references'])){ |
|
239 | - $this->syntax[]=$this->getReferenceSyntax($this->data['references']); |
|
238 | + if (count($this->data['references'])) { |
|
239 | + $this->syntax[] = $this->getReferenceSyntax($this->data['references']); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 |
@@ -94,8 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | if(current($syntaxList)!==$changeAbleField){ |
96 | 96 | $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
97 | - } |
|
98 | - else{ |
|
97 | + } else{ |
|
99 | 98 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
100 | 99 | } |
101 | 100 | |
@@ -167,8 +166,7 @@ discard block |
||
167 | 166 | //get table collation |
168 | 167 | if(isset($this->data['tableCollation']['table'])){ |
169 | 168 | $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
170 | - } |
|
171 | - else{ |
|
169 | + } else{ |
|
172 | 170 | $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
173 | 171 | } |
174 | 172 | |
@@ -176,8 +174,7 @@ discard block |
||
176 | 174 | if($this->data['engine']!==null) |
177 | 175 | { |
178 | 176 | $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
179 | - } |
|
180 | - else{ |
|
177 | + } else{ |
|
181 | 178 | $this->syntax[]=' ENGINE=InnoDB '; |
182 | 179 | } |
183 | 180 | |
@@ -185,8 +182,7 @@ discard block |
||
185 | 182 | |
186 | 183 | if(in_array($this->table,$existTables)){ |
187 | 184 | return false; |
188 | - } |
|
189 | - else{ |
|
185 | + } else{ |
|
190 | 186 | $query=$this->schema->getConnection()->setQueryBasic($syntax); |
191 | 187 | |
192 | 188 | return [ |
@@ -211,8 +207,7 @@ discard block |
||
211 | 207 | |
212 | 208 | if($group=='create'){ |
213 | 209 | $this->syntax[]=','.implode(',',$this->data['uniqueValueList']); |
214 | - } |
|
215 | - else{ |
|
210 | + } else{ |
|
216 | 211 | $this->alterExtras[]='ADD '.implode(',',$this->data['uniqueValueList']); |
217 | 212 | } |
218 | 213 | |
@@ -223,8 +218,7 @@ discard block |
||
223 | 218 | |
224 | 219 | if($group=='create'){ |
225 | 220 | $this->syntax[]=','.implode(',',$this->data['indexValueList']); |
226 | - } |
|
227 | - else{ |
|
221 | + } else{ |
|
228 | 222 | $this->alterExtras[]='ADD '.implode(',',$this->data['indexValueList']); |
229 | 223 | } |
230 | 224 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Migratio\Contract\WizardContract; |
6 | 6 | use Migratio\Contract\WizardAlterContract; |
7 | 7 | |
8 | -class WizardAlter extends Wizard implements WizardContract,WizardAlterContract |
|
8 | +class WizardAlter extends Wizard implements WizardContract, WizardAlterContract |
|
9 | 9 | { |
10 | 10 | /** |
11 | 11 | * @var array |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function after($field) |
34 | 34 | { |
35 | - $this->wizard->setAlterType('place',['AFTER'=>$field]); |
|
35 | + $this->wizard->setAlterType('place', ['AFTER'=>$field]); |
|
36 | 36 | |
37 | 37 | return $this->wizard; |
38 | 38 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var $type |
17 | 17 | */ |
18 | - public $type='migration'; |
|
18 | + public $type = 'migration'; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var array |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @var $commandRule |
35 | 35 | */ |
36 | - public $commandRule=['create'=>[ |
|
37 | - 'name','table' |
|
36 | + public $commandRule = ['create'=>[ |
|
37 | + 'name', 'table' |
|
38 | 38 | ], |
39 | 39 | 'push'=>[]]; |
40 | 40 | |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | |
64 | 64 | foreach ($pushResult as $key=>$value) { |
65 | 65 | |
66 | - if(isset($value['success'])){ |
|
66 | + if (isset($value['success'])) { |
|
67 | 67 | |
68 | 68 | $list[] = true; |
69 | 69 | |
70 | - $pushResultFile = explode("/",$pushResult[$key]['file']); |
|
70 | + $pushResultFile = explode("/", $pushResult[$key]['file']); |
|
71 | 71 | $file = end($pushResultFile); |
72 | 72 | |
73 | - if($pushResult[$key]['success']===true){ |
|
73 | + if ($pushResult[$key]['success']===true) { |
|
74 | 74 | |
75 | 75 | $this->table->addRow([ |
76 | 76 | $key, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'No', |
83 | 83 | ]); |
84 | 84 | } |
85 | - else{ |
|
85 | + else { |
|
86 | 86 | |
87 | 87 | $this->table->addRow([ |
88 | 88 | $key, |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - if(count($list)){ |
|
102 | - $this->table->setHeaders(['id','table','file','type','status','message','seeder']); |
|
101 | + if (count($list)) { |
|
102 | + $this->table->setHeaders(['id', 'table', 'file', 'type', 'status', 'message', 'seeder']); |
|
103 | 103 | |
104 | 104 | echo $this->table->getTable(); |
105 | 105 | } |
106 | - else{ |
|
106 | + else { |
|
107 | 107 | echo $this->classical('No migration was found to apply'); |
108 | 108 | } |
109 | 109 | |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | { |
118 | 118 | $config = $this->getConfig(); |
119 | 119 | |
120 | - if(!isset($this->argument['group'])){ |
|
120 | + if (!isset($this->argument['group'])) { |
|
121 | 121 | $path = $config['paths'][0]; |
122 | 122 | } |
123 | - else{ |
|
123 | + else { |
|
124 | 124 | $path = $config['paths'][strtolower($this->argument['group'])]; |
125 | 125 | } |
126 | 126 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | |
131 | 131 | $stubType = (!file_exists($tablePath)) ? 'create' : 'alter'; |
132 | 132 | |
133 | - if(!file_exists($path)){ |
|
133 | + if (!file_exists($path)) { |
|
134 | 134 | |
135 | - $this->file->fs->mkdir($path,0777); |
|
136 | - $this->file->fs->chmod($path,0777,000,true); |
|
135 | + $this->file->fs->mkdir($path, 0777); |
|
136 | + $this->file->fs->chmod($path, 0777, 000, true); |
|
137 | 137 | } |
138 | 138 | |
139 | - $migrationCreate = $this->getSchema()->stub($this->argument,$stubType); |
|
139 | + $migrationCreate = $this->getSchema()->stub($this->argument, $stubType); |
|
140 | 140 | |
141 | 141 | echo $this->info('Migration Create Process :'); |
142 | 142 | |
143 | - $this->table->setHeaders(['id','method','table','style','name','type','status','message']); |
|
143 | + $this->table->setHeaders(['id', 'method', 'table', 'style', 'name', 'type', 'status', 'message']); |
|
144 | 144 | |
145 | - foreach ($migrationCreate['directory'] as $key=>$data){ |
|
145 | + foreach ($migrationCreate['directory'] as $key=>$data) { |
|
146 | 146 | |
147 | 147 | $this->table->addRow([ |
148 | 148 | $key, |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | ]); |
158 | 158 | } |
159 | 159 | |
160 | - foreach ($migrationCreate['file'] as $key=>$data){ |
|
160 | + foreach ($migrationCreate['file'] as $key=>$data) { |
|
161 | 161 | |
162 | 162 | $this->table->addRow([ |
163 | 163 | $key, |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | 'arguments' => $this->argument |
189 | 189 | ]; |
190 | 190 | |
191 | - $paths['paths'] = array_merge($paths['paths'],[StaticPathModel::storeMigrationPath()]); |
|
191 | + $paths['paths'] = array_merge($paths['paths'], [StaticPathModel::storeMigrationPath()]); |
|
192 | 192 | |
193 | 193 | foreach (config('database.migrations') as $key=>$item) { |
194 | - if($key!=='default'){ |
|
194 | + if ($key!=='default') { |
|
195 | 195 | |
196 | 196 | $otherMigrationPath = path()->migration().''.$item; |
197 | - $paths['paths'] = array_merge($paths['paths'],[$key=>$otherMigrationPath]); |
|
197 | + $paths['paths'] = array_merge($paths['paths'], [$key=>$otherMigrationPath]); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 |
@@ -81,8 +81,7 @@ discard block |
||
81 | 81 | 'Ok', |
82 | 82 | 'No', |
83 | 83 | ]); |
84 | - } |
|
85 | - else{ |
|
84 | + } else{ |
|
86 | 85 | |
87 | 86 | $this->table->addRow([ |
88 | 87 | $key, |
@@ -102,8 +101,7 @@ discard block |
||
102 | 101 | $this->table->setHeaders(['id','table','file','type','status','message','seeder']); |
103 | 102 | |
104 | 103 | echo $this->table->getTable(); |
105 | - } |
|
106 | - else{ |
|
104 | + } else{ |
|
107 | 105 | echo $this->classical('No migration was found to apply'); |
108 | 106 | } |
109 | 107 | |
@@ -119,8 +117,7 @@ discard block |
||
119 | 117 | |
120 | 118 | if(!isset($this->argument['group'])){ |
121 | 119 | $path = $config['paths'][0]; |
122 | - } |
|
123 | - else{ |
|
120 | + } else{ |
|
124 | 121 | $path = $config['paths'][strtolower($this->argument['group'])]; |
125 | 122 | } |
126 | 123 |