@@ -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 string |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function after($field) |
29 | 29 | { |
30 | - $this->wizard->setAlterType('place',['AFTER'=>$field]); |
|
30 | + $this->wizard->setAlterType('place', ['AFTER'=>$field]); |
|
31 | 31 | |
32 | 32 | return $this->wizard; |
33 | 33 | } |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function __construct($wizard) |
19 | 19 | { |
20 | - $this->wizard=$wizard; |
|
20 | + $this->wizard = $wizard; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param null|string $value |
25 | 25 | * @return WizardContract |
26 | 26 | */ |
27 | - public function bigint($value=20) |
|
27 | + public function bigint($value = 20) |
|
28 | 28 | { |
29 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
29 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
30 | 30 | |
31 | 31 | return $this->wizard; |
32 | 32 | } |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param null|string $value |
36 | 36 | * @return WizardContract |
37 | 37 | */ |
38 | - public function binary($value=null) |
|
38 | + public function binary($value = null) |
|
39 | 39 | { |
40 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
40 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
41 | 41 | |
42 | 42 | return $this->wizard; |
43 | 43 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param null|string $value |
47 | 47 | * @return WizardContract |
48 | 48 | */ |
49 | - public function bit($value=null) |
|
49 | + public function bit($value = null) |
|
50 | 50 | { |
51 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
51 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
52 | 52 | |
53 | 53 | return $this->wizard; |
54 | 54 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function blob() |
60 | 60 | { |
61 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
61 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
62 | 62 | |
63 | 63 | return $this->wizard; |
64 | 64 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function char($value) |
71 | 71 | { |
72 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
72 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
73 | 73 | |
74 | 74 | return $this->wizard; |
75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function date() |
81 | 81 | { |
82 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
82 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
83 | 83 | |
84 | 84 | return $this->wizard; |
85 | 85 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function dateTime() |
91 | 91 | { |
92 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
92 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
93 | 93 | |
94 | 94 | return $this->wizard; |
95 | 95 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function decimal() |
101 | 101 | { |
102 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
102 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
103 | 103 | |
104 | 104 | return $this->wizard; |
105 | 105 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function double() |
111 | 111 | { |
112 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
112 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
113 | 113 | |
114 | 114 | return $this->wizard; |
115 | 115 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * @param $value |
119 | 119 | * @return WizardContract |
120 | 120 | */ |
121 | - public function enum($value=array()) |
|
121 | + public function enum($value = array()) |
|
122 | 122 | { |
123 | - $this->wizard->setTypes(__FUNCTION__,$value,'enum'); |
|
123 | + $this->wizard->setTypes(__FUNCTION__, $value, 'enum'); |
|
124 | 124 | |
125 | 125 | return $this->wizard; |
126 | 126 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function float() |
132 | 132 | { |
133 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
133 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
134 | 134 | |
135 | 135 | return $this->wizard; |
136 | 136 | } |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | * @param int $value |
140 | 140 | * @return WizardContract |
141 | 141 | */ |
142 | - public function int($value=11) |
|
142 | + public function int($value = 11) |
|
143 | 143 | { |
144 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
144 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
145 | 145 | |
146 | 146 | return $this->wizard; |
147 | 147 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function longtext() |
153 | 153 | { |
154 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
154 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
155 | 155 | |
156 | 156 | return $this->wizard; |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function mediumtext() |
163 | 163 | { |
164 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
164 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
165 | 165 | |
166 | 166 | return $this->wizard; |
167 | 167 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function json() |
174 | 174 | { |
175 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
175 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
176 | 176 | |
177 | 177 | return $this->wizard; |
178 | 178 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function set($value) |
185 | 185 | { |
186 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
186 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
187 | 187 | |
188 | 188 | return $this->wizard; |
189 | 189 | } |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * @param null|string $value |
193 | 193 | * @return WizardContract |
194 | 194 | */ |
195 | - public function text($value=null) |
|
195 | + public function text($value = null) |
|
196 | 196 | { |
197 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
197 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
198 | 198 | |
199 | 199 | return $this->wizard; |
200 | 200 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * @param null|string $value |
204 | 204 | * @return WizardContract |
205 | 205 | */ |
206 | - public function time($value=null) |
|
206 | + public function time($value = null) |
|
207 | 207 | { |
208 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
208 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
209 | 209 | |
210 | 210 | return $this->wizard; |
211 | 211 | } |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | * @param mixed $value |
215 | 215 | * @return WizardContract |
216 | 216 | */ |
217 | - public function mediumint($value=8) |
|
217 | + public function mediumint($value = 8) |
|
218 | 218 | { |
219 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
219 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
220 | 220 | |
221 | 221 | return $this->wizard; |
222 | 222 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | * @param mixed $value |
226 | 226 | * @return WizardContract |
227 | 227 | */ |
228 | - public function mediumblob($value=null) |
|
228 | + public function mediumblob($value = null) |
|
229 | 229 | { |
230 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
230 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
231 | 231 | |
232 | 232 | return $this->wizard; |
233 | 233 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function timestamp() |
240 | 240 | { |
241 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
241 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
242 | 242 | |
243 | 243 | return $this->wizard; |
244 | 244 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function real() |
250 | 250 | { |
251 | - $this->wizard->setTypes(__FUNCTION__,null); |
|
251 | + $this->wizard->setTypes(__FUNCTION__, null); |
|
252 | 252 | |
253 | 253 | return $this->wizard; |
254 | 254 | } |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @param mixed $value |
258 | 258 | * @return WizardContract |
259 | 259 | */ |
260 | - public function smallint($value=5) |
|
260 | + public function smallint($value = 5) |
|
261 | 261 | { |
262 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
262 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
263 | 263 | |
264 | 264 | return $this->wizard; |
265 | 265 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | * @param mixed $value |
269 | 269 | * @return WizardContract |
270 | 270 | */ |
271 | - public function tinyint($value=3) |
|
271 | + public function tinyint($value = 3) |
|
272 | 272 | { |
273 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
273 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
274 | 274 | |
275 | 275 | return $this->wizard; |
276 | 276 | } |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * @param null|string $value |
280 | 280 | * @return WizardContract |
281 | 281 | */ |
282 | - public function tinytext($value=null) |
|
282 | + public function tinytext($value = null) |
|
283 | 283 | { |
284 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
284 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
285 | 285 | |
286 | 286 | return $this->wizard; |
287 | 287 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function varchar($value) |
294 | 294 | { |
295 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
295 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
296 | 296 | |
297 | 297 | return $this->wizard; |
298 | 298 | } |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @param null|string $value |
302 | 302 | * @return WizardContract |
303 | 303 | */ |
304 | - public function year($value=null) |
|
304 | + public function year($value = null) |
|
305 | 305 | { |
306 | - $this->wizard->setTypes(__FUNCTION__,$value); |
|
306 | + $this->wizard->setTypes(__FUNCTION__, $value); |
|
307 | 307 | |
308 | 308 | return $this->wizard; |
309 | 309 | } |
@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | * @param $name |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - protected function getNullableValue($nullable,$name) |
|
13 | + protected function getNullableValue($nullable, $name) |
|
14 | 14 | { |
15 | - $nullableValue=''; |
|
15 | + $nullableValue = ''; |
|
16 | 16 | |
17 | - if(isset($nullable[$name])){ |
|
18 | - if($nullable[$name]===false){ |
|
19 | - $nullableValue='NOT NULL'; |
|
17 | + if (isset($nullable[$name])) { |
|
18 | + if ($nullable[$name]===false) { |
|
19 | + $nullableValue = 'NOT NULL'; |
|
20 | 20 | } |
21 | - else{ |
|
22 | - $nullableValue='NULL'; |
|
21 | + else { |
|
22 | + $nullableValue = 'NULL'; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function getValueWithIsset($name) |
61 | 61 | { |
62 | - $nameKey = array_search($name,$this->data['names']); |
|
62 | + $nameKey = array_search($name, $this->data['names']); |
|
63 | 63 | |
64 | 64 | $list = []; |
65 | - $list[] = $this->getNullableValue($this->data['nullable'],$name); |
|
65 | + $list[] = $this->getNullableValue($this->data['nullable'], $name); |
|
66 | 66 | $list[] = (isset($this->data['autoIncrement'][$name])) ? 'AUTO_INCREMENT' : ''; |
67 | 67 | $list[] = (isset($this->data['primaryKey'][$name])) ? 'PRIMARY KEY' : ''; |
68 | 68 | |
69 | - if($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])){ |
|
69 | + if ($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])) { |
|
70 | 70 | $this->data['default'][$name] = 'CURRENT_TIMESTAMP'; |
71 | 71 | } |
72 | 72 | |
73 | - if($this->data['types'][$nameKey]!=='timestamp'){ |
|
73 | + if ($this->data['types'][$nameKey]!=='timestamp') { |
|
74 | 74 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
75 | 75 | } |
76 | - else{ |
|
76 | + else { |
|
77 | 77 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
78 | 78 | } |
79 | 79 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | protected function getUniqueValueList($name) |
91 | 91 | { |
92 | 92 | //get unique |
93 | - if(isset($this->data['unique'][$name])){ |
|
94 | - $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$name.' ('.$this->data['unique'][$name]['value'].' ASC)'; |
|
93 | + if (isset($this->data['unique'][$name])) { |
|
94 | + $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$name.' ('.$this->data['unique'][$name]['value'].' ASC)'; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | protected function getIndexValueList($name) |
102 | 102 | { |
103 | 103 | //get index |
104 | - if(isset($this->data['index'][$name])){ |
|
105 | - $this->data['indexValueList'][] = 'INDEX '.$name.' ('.$this->data['index'][$name]['value'].')'; |
|
104 | + if (isset($this->data['index'][$name])) { |
|
105 | + $this->data['indexValueList'][] = 'INDEX '.$name.' ('.$this->data['index'][$name]['value'].')'; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -123,19 +123,19 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function getCreateDefaultList() |
125 | 125 | { |
126 | - $list = []; |
|
126 | + $list = []; |
|
127 | 127 | |
128 | 128 | foreach ($this->data['names'] as $key=>$name) |
129 | 129 | { |
130 | 130 | list( |
131 | - $nullableValue,$autoIncrementValue, |
|
132 | - $primaryKeyValue,$defaultValue,$commentValue |
|
131 | + $nullableValue, $autoIncrementValue, |
|
132 | + $primaryKeyValue, $defaultValue, $commentValue |
|
133 | 133 | ) = $this->getValueWithIsset($name); |
134 | 134 | |
135 | 135 | //set index values |
136 | 136 | $this->setIndex($name); |
137 | 137 | |
138 | - $list[]=''.$name.' '.$this->data['types'][$key].' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
138 | + $list[] = ''.$name.' '.$this->data['types'][$key].' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $list; |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function getKeyList() |
148 | 148 | { |
149 | - $keyList = []; |
|
149 | + $keyList = []; |
|
150 | 150 | |
151 | 151 | //multiple indexes |
152 | - if(isset($this->data['index']['indexes'])){ |
|
152 | + if (isset($this->data['index']['indexes'])) { |
|
153 | 153 | |
154 | - foreach ($this->data['index']['indexes'] as $index_key=>$index_value){ |
|
154 | + foreach ($this->data['index']['indexes'] as $index_key=>$index_value) { |
|
155 | 155 | |
156 | 156 | $indexesCommentValue = (isset($index_value['comment'])) ? 'COMMENT "'.$index_value['comment'].'"' : ''; |
157 | 157 | |
158 | 158 | $keyType = (isset($index_value['type'])) ? ucfirst($index_value['type']) : 'KEY'; |
159 | 159 | |
160 | - $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",",$index_value['value']).") ".$indexesCommentValue; |
|
160 | + $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",", $index_value['value']).") ".$indexesCommentValue; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | { |
173 | 173 | $list = []; |
174 | 174 | |
175 | - foreach ($reference as $constraint=>$values){ |
|
175 | + foreach ($reference as $constraint=>$values) { |
|
176 | 176 | |
177 | - $list[]=',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
177 | + $list[] = ',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
178 | 178 | REFERENCES '.$values['references']['table'].'('.$values['references']['field'].') '.$this->getOnProcess($values); |
179 | 179 | } |
180 | 180 | |
181 | - return implode (" ",$list); |
|
181 | + return implode(" ", $list); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function getOnProcess($referenceValue) |
188 | 188 | { |
189 | - if(isset($referenceValue['on']) && isset($referenceValue['onOption'])){ |
|
189 | + if (isset($referenceValue['on']) && isset($referenceValue['onOption'])) { |
|
190 | 190 | return ''.$referenceValue['on'].' '.strtoupper($referenceValue['onOption']).''; |
191 | 191 | } |
192 | 192 |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | if(isset($nullable[$name])){ |
18 | 18 | if($nullable[$name]===false){ |
19 | 19 | $nullableValue='NOT NULL'; |
20 | - } |
|
21 | - else{ |
|
20 | + } else{ |
|
22 | 21 | $nullableValue='NULL'; |
23 | 22 | } |
24 | 23 | } |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | |
73 | 72 | if($this->data['types'][$nameKey]!=='timestamp'){ |
74 | 73 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
75 | - } |
|
76 | - else{ |
|
74 | + } else{ |
|
77 | 75 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
78 | 76 | } |
79 | 77 |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | |
26 | 26 | $this->getDefaultSyntaxGroup(); |
27 | 27 | |
28 | - $this->syntax[]=')'; |
|
28 | + $this->syntax[] = ')'; |
|
29 | 29 | |
30 | 30 | //get table collation |
31 | - if(isset($this->data['tableCollation']['table'])){ |
|
32 | - $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
31 | + if (isset($this->data['tableCollation']['table'])) { |
|
32 | + $this->syntax[] = ' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
33 | 33 | } |
34 | - else{ |
|
35 | - $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
|
34 | + else { |
|
35 | + $this->syntax[] = ' DEFAULT CHARACTER SET utf8'; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | //get engine |
39 | - if($this->data['engine']!==null) |
|
39 | + if ($this->data['engine']!==null) |
|
40 | 40 | { |
41 | - $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
|
41 | + $this->syntax[] = ' ENGINE='.$this->data['engine'].' '; |
|
42 | 42 | } |
43 | - else{ |
|
44 | - $this->syntax[]=' ENGINE=InnoDB '; |
|
43 | + else { |
|
44 | + $this->syntax[] = ' ENGINE=InnoDB '; |
|
45 | 45 | } |
46 | 46 | |
47 | - $syntax = implode("",$this->syntax); |
|
47 | + $syntax = implode("", $this->syntax); |
|
48 | 48 | |
49 | - $query=$this->schema->getConnection()->setQueryBasic($syntax); |
|
49 | + $query = $this->schema->getConnection()->setQueryBasic($syntax); |
|
50 | 50 | |
51 | 51 | return [ |
52 | 52 | 'syntax'=>$syntax, |
@@ -62,25 +62,25 @@ discard block |
||
62 | 62 | private function getDefaultSyntaxGroup() |
63 | 63 | { |
64 | 64 | |
65 | - $this->syntax[]=implode(",",$this->getCreateDefaultList()); |
|
65 | + $this->syntax[] = implode(",", $this->getCreateDefaultList()); |
|
66 | 66 | |
67 | 67 | //get unique values |
68 | - if(isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])){ |
|
69 | - $this->syntax[]=','.implode(',',$this->data['uniqueValueList']); |
|
68 | + if (isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])) { |
|
69 | + $this->syntax[] = ','.implode(',', $this->data['uniqueValueList']); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | //get index values |
73 | - if(isset($this->data['indexValueList']) && count($this->data['indexValueList'])){ |
|
74 | - $this->syntax[]=','.implode(',',$this->data['indexValueList']); |
|
73 | + if (isset($this->data['indexValueList']) && count($this->data['indexValueList'])) { |
|
74 | + $this->syntax[] = ','.implode(',', $this->data['indexValueList']); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | //get index values for key |
78 | - if(count($this->getKeyList())){ |
|
79 | - $this->syntax[]=','.implode(',',$this->getKeyList()); |
|
78 | + if (count($this->getKeyList())) { |
|
79 | + $this->syntax[] = ','.implode(',', $this->getKeyList()); |
|
80 | 80 | } |
81 | 81 | |
82 | - if(count($this->data['references'])){ |
|
83 | - $this->syntax[]=$this->getReferenceSyntax($this->data['references']); |
|
82 | + if (count($this->data['references'])) { |
|
83 | + $this->syntax[] = $this->getReferenceSyntax($this->data['references']); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -104,33 +104,33 @@ discard block |
||
104 | 104 | |
105 | 105 | private function change($alterType) |
106 | 106 | { |
107 | - if(isset($alterType['place'])){ |
|
107 | + if (isset($alterType['place'])) { |
|
108 | 108 | |
109 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
110 | - $placeList=$placeKey .' '.$placeValue.''; |
|
109 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
110 | + $placeList = $placeKey.' '.$placeValue.''; |
|
111 | 111 | } |
112 | 112 | |
113 | - $syntax = implode("",$this->syntax); |
|
113 | + $syntax = implode("", $this->syntax); |
|
114 | 114 | |
115 | 115 | $columns = $this->schema->getConnection()->showColumnsFrom($this->table); |
116 | 116 | |
117 | - foreach ($columns as $columnKey=>$columnData){ |
|
118 | - if($columnData['Field']==$placeValue){ |
|
117 | + foreach ($columns as $columnKey=>$columnData) { |
|
118 | + if ($columnData['Field']==$placeValue) { |
|
119 | 119 | $changeAbleField = $columns[$columnKey+1]['Field']; |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | - $syntaxList = explode(' ',$syntax); |
|
123 | + $syntaxList = explode(' ', $syntax); |
|
124 | 124 | |
125 | - if(current($syntaxList)!==$changeAbleField){ |
|
126 | - $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
|
125 | + if (current($syntaxList)!==$changeAbleField) { |
|
126 | + $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ', array_splice($syntaxList, 1)).' '.$placeList; |
|
127 | 127 | } |
128 | - else{ |
|
128 | + else { |
|
129 | 129 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
130 | 130 | } |
131 | 131 | |
132 | 132 | |
133 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
133 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
134 | 134 | |
135 | 135 | return [ |
136 | 136 | 'syntax'=>$syntax, |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | |
144 | 144 | private function addColumn($alterType) |
145 | 145 | { |
146 | - if(isset($alterType['place'])){ |
|
146 | + if (isset($alterType['place'])) { |
|
147 | 147 | |
148 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
149 | - $placeList=$placeKey .' '.$placeValue.''; |
|
148 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
149 | + $placeList = $placeKey.' '.$placeValue.''; |
|
150 | 150 | } |
151 | 151 | |
152 | - $syntax = implode("",$this->syntax); |
|
152 | + $syntax = implode("", $this->syntax); |
|
153 | 153 | |
154 | 154 | $alterSytanx = 'ALTER TABLE '.$this->table.' ADD COLUMN '.$syntax.' '.$placeList; |
155 | 155 | |
156 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
156 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
157 | 157 | |
158 | 158 | return [ |
159 | 159 | 'syntax'=>$syntax, |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | //get table collation |
31 | 31 | if(isset($this->data['tableCollation']['table'])){ |
32 | 32 | $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
33 | - } |
|
34 | - else{ |
|
33 | + } else{ |
|
35 | 34 | $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
36 | 35 | } |
37 | 36 | |
@@ -39,8 +38,7 @@ discard block |
||
39 | 38 | if($this->data['engine']!==null) |
40 | 39 | { |
41 | 40 | $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
42 | - } |
|
43 | - else{ |
|
41 | + } else{ |
|
44 | 42 | $this->syntax[]=' ENGINE=InnoDB '; |
45 | 43 | } |
46 | 44 | |
@@ -124,8 +122,7 @@ discard block |
||
124 | 122 | |
125 | 123 | if(current($syntaxList)!==$changeAbleField){ |
126 | 124 | $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
127 | - } |
|
128 | - else{ |
|
125 | + } else{ |
|
129 | 126 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
130 | 127 | } |
131 | 128 |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | |
21 | 21 | $list = []; |
22 | 22 | |
23 | - foreach ($migrations as $table=>$item){ |
|
23 | + foreach ($migrations as $table=>$item) { |
|
24 | 24 | $list[] = strtolower($table); |
25 | 25 | } |
26 | 26 | |
27 | - foreach ($dbtables as $dbtable){ |
|
27 | + foreach ($dbtables as $dbtable) { |
|
28 | 28 | //if(!in_array($dbtable,$list)){ |
29 | 29 | |
30 | 30 | $informations = $this->tableInformations($dbtable); |
31 | 31 | |
32 | 32 | $dbtable = ucfirst($dbtable); |
33 | 33 | $makeDirectory = $directory.''.DIRECTORY_SEPARATOR.''.$dbtable; |
34 | - files()->makeDirectory($makeDirectory,0755,true); |
|
34 | + files()->makeDirectory($makeDirectory, 0755, true); |
|
35 | 35 | |
36 | 36 | $migrationName = time().'_'.$dbtable.''; |
37 | 37 | |
38 | - $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub',[ |
|
38 | + $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub', [ |
|
39 | 39 | 'className' => $dbtable, |
40 | 40 | 'informations' => $informations |
41 | 41 | ]); |
42 | 42 | |
43 | - files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php',$content); |
|
43 | + files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php', $content); |
|
44 | 44 | |
45 | 45 | /**if(substr($dbtable,-1)=='s'){ |
46 | 46 | app()->command('model create','model:'.strtolower(substr($dbtable,0,-1))); |
@@ -73,46 +73,46 @@ discard block |
||
73 | 73 | |
74 | 74 | $list = []; |
75 | 75 | |
76 | - foreach ($columns as $key=>$data){ |
|
76 | + foreach ($columns as $key=>$data) { |
|
77 | 77 | |
78 | - $data['Type'] = rtrim(str_replace('unsigned','',$data['Type'])); |
|
78 | + $data['Type'] = rtrim(str_replace('unsigned', '', $data['Type'])); |
|
79 | 79 | |
80 | 80 | $field = $data['Field']; |
81 | 81 | $list[] = '$wizard->name(\''.$field.'\')'; |
82 | 82 | $list[] = '->'.$this->getColumnTransformers($data['Type']).''; |
83 | 83 | |
84 | 84 | //default block |
85 | - if(!is_null($data['Default'])){ |
|
85 | + if (!is_null($data['Default'])) { |
|
86 | 86 | $default = $data['Default']; |
87 | - $list[] = '->default(\''.$default.'\')'; |
|
87 | + $list[] = '->default(\''.$default.'\')'; |
|
88 | 88 | } |
89 | 89 | |
90 | - $getIndex = $this->getIndexInformation($indexes,$data['Field']); |
|
90 | + $getIndex = $this->getIndexInformation($indexes, $data['Field']); |
|
91 | 91 | |
92 | 92 | //unique block |
93 | - if($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY'){ |
|
93 | + if ($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY') { |
|
94 | 94 | $indexName = $getIndex['Key_name']; |
95 | - $list[] = '->unique(\''.$indexName.'\')'; |
|
95 | + $list[] = '->unique(\''.$indexName.'\')'; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | //index block |
99 | - if($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY'){ |
|
99 | + if ($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY') { |
|
100 | 100 | $columnName = $getIndex['Column_name']; |
101 | 101 | $indexName = $getIndex['Key_name']; |
102 | 102 | |
103 | - if(count($multipleIndexes[$indexName])==1){ |
|
103 | + if (count($multipleIndexes[$indexName])==1) { |
|
104 | 104 | $list[] = '->index(\''.$indexName.'\')'; |
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | 108 | //comment block |
109 | - if(strlen($data['Comment'])>0){ |
|
109 | + if (strlen($data['Comment'])>0) { |
|
110 | 110 | $comment = $data['Comment']; |
111 | 111 | $list[] = '->comment(\''.$comment.'\')'; |
112 | 112 | } |
113 | 113 | |
114 | 114 | //auto increment block |
115 | - if($data['Extra']=='auto_increment'){ |
|
115 | + if ($data['Extra']=='auto_increment') { |
|
116 | 116 | $list[] = '->auto_increment()'; |
117 | 117 | } |
118 | 118 | |
@@ -127,39 +127,39 @@ discard block |
||
127 | 127 | |
128 | 128 | //table indexes |
129 | 129 | foreach ($multipleIndexes as $indexName=>$values) { |
130 | - if(count($values)>1){ |
|
131 | - $values = '\''.implode('\',\'',$values).'\''; |
|
130 | + if (count($values)>1) { |
|
131 | + $values = '\''.implode('\',\'', $values).'\''; |
|
132 | 132 | $list[] = ' $wizard->table()->indexes(\''.$indexName.'\',['.$values.']); |
133 | 133 | '; |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - if(count($foreignKeys)){ |
|
137 | + if (count($foreignKeys)) { |
|
138 | 138 | |
139 | 139 | $constraintName = $foreignKeys['CONSTRAINT_NAME']; |
140 | 140 | $key = $foreignKeys['COLUMN_NAME']; |
141 | 141 | $referenceTable = $foreignKeys['REFERENCED_TABLE_NAME']; |
142 | 142 | $referenceColumn = $foreignKeys['REFERENCED_COLUMN_NAME']; |
143 | 143 | |
144 | - if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){ |
|
144 | + if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') { |
|
145 | 145 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\'); |
146 | 146 | '; |
147 | 147 | } |
148 | 148 | |
149 | - if($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){ |
|
149 | + if ($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') { |
|
150 | 150 | $rule = $foreignKeys['UPDATE_RULE']; |
151 | 151 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onUpdate()->'.strtolower($rule).'(); |
152 | 152 | '; |
153 | 153 | } |
154 | 154 | |
155 | - if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT'){ |
|
155 | + if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT') { |
|
156 | 156 | $rule = $foreignKeys['DELETE_RULE']; |
157 | 157 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onDelete()->'.strtolower($rule).'(); |
158 | 158 | '; |
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - return implode('',$list); |
|
162 | + return implode('', $list); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -170,43 +170,43 @@ discard block |
||
170 | 170 | */ |
171 | 171 | private function getColumnTransformers($column) |
172 | 172 | { |
173 | - if($column=='datetime'){ |
|
173 | + if ($column=='datetime') { |
|
174 | 174 | return 'datetime()'; |
175 | 175 | } |
176 | - elseif($column=='longtext'){ |
|
176 | + elseif ($column=='longtext') { |
|
177 | 177 | return 'longtext()'; |
178 | 178 | } |
179 | - elseif($column=='date'){ |
|
179 | + elseif ($column=='date') { |
|
180 | 180 | return 'date()'; |
181 | 181 | } |
182 | - elseif($column=='text'){ |
|
182 | + elseif ($column=='text') { |
|
183 | 183 | return 'text()'; |
184 | 184 | } |
185 | - elseif($column=='timestamp'){ |
|
185 | + elseif ($column=='timestamp') { |
|
186 | 186 | return 'timestamp'; |
187 | 187 | } |
188 | - elseif($column=='mediumint'){ |
|
188 | + elseif ($column=='mediumint') { |
|
189 | 189 | return 'mediumint()'; |
190 | 190 | } |
191 | - elseif($column=='tinyint'){ |
|
191 | + elseif ($column=='tinyint') { |
|
192 | 192 | return 'tinyint()'; |
193 | 193 | } |
194 | - elseif($column=='float'){ |
|
194 | + elseif ($column=='float') { |
|
195 | 195 | return 'float()'; |
196 | 196 | } |
197 | - elseif($column=='mediumtext'){ |
|
197 | + elseif ($column=='mediumtext') { |
|
198 | 198 | return 'mediumtext()'; |
199 | 199 | } |
200 | - elseif($column=='mediumblob'){ |
|
200 | + elseif ($column=='mediumblob') { |
|
201 | 201 | return 'mediumblob()'; |
202 | 202 | } |
203 | - elseif($column=='blob'){ |
|
203 | + elseif ($column=='blob') { |
|
204 | 204 | return 'blob()'; |
205 | 205 | } |
206 | - elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
206 | + elseif (preg_match('@enum.*\((.*?)\)@', $column, $enum)) { |
|
207 | 207 | return 'enum(['.$enum[1].'])'; |
208 | 208 | } |
209 | - else{ |
|
209 | + else { |
|
210 | 210 | return $column; |
211 | 211 | } |
212 | 212 | } |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | * @param $field |
219 | 219 | * @return void|mixed |
220 | 220 | */ |
221 | - private function getIndexInformation($index,$field) |
|
221 | + private function getIndexInformation($index, $field) |
|
222 | 222 | { |
223 | 223 | foreach ($index as $key=>$item) { |
224 | 224 | |
225 | - if($item['Column_name'] == $field){ |
|
225 | + if ($item['Column_name']==$field) { |
|
226 | 226 | return $index[$key]; |
227 | 227 | } |
228 | 228 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | { |
242 | 242 | $list = []; |
243 | 243 | foreach ($index as $key=>$item) { |
244 | - if($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY'){ |
|
244 | + if ($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY') { |
|
245 | 245 | $list[$item['Key_name']][] = $item['Column_name']; |
246 | 246 | } |
247 | 247 | } |
@@ -172,41 +172,29 @@ |
||
172 | 172 | { |
173 | 173 | if($column=='datetime'){ |
174 | 174 | return 'datetime()'; |
175 | - } |
|
176 | - elseif($column=='longtext'){ |
|
175 | + } elseif($column=='longtext'){ |
|
177 | 176 | return 'longtext()'; |
178 | - } |
|
179 | - elseif($column=='date'){ |
|
177 | + } elseif($column=='date'){ |
|
180 | 178 | return 'date()'; |
181 | - } |
|
182 | - elseif($column=='text'){ |
|
179 | + } elseif($column=='text'){ |
|
183 | 180 | return 'text()'; |
184 | - } |
|
185 | - elseif($column=='timestamp'){ |
|
181 | + } elseif($column=='timestamp'){ |
|
186 | 182 | return 'timestamp'; |
187 | - } |
|
188 | - elseif($column=='mediumint'){ |
|
183 | + } elseif($column=='mediumint'){ |
|
189 | 184 | return 'mediumint()'; |
190 | - } |
|
191 | - elseif($column=='tinyint'){ |
|
185 | + } elseif($column=='tinyint'){ |
|
192 | 186 | return 'tinyint()'; |
193 | - } |
|
194 | - elseif($column=='float'){ |
|
187 | + } elseif($column=='float'){ |
|
195 | 188 | return 'float()'; |
196 | - } |
|
197 | - elseif($column=='mediumtext'){ |
|
189 | + } elseif($column=='mediumtext'){ |
|
198 | 190 | return 'mediumtext()'; |
199 | - } |
|
200 | - elseif($column=='mediumblob'){ |
|
191 | + } elseif($column=='mediumblob'){ |
|
201 | 192 | return 'mediumblob()'; |
202 | - } |
|
203 | - elseif($column=='blob'){ |
|
193 | + } elseif($column=='blob'){ |
|
204 | 194 | return 'blob()'; |
205 | - } |
|
206 | - elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
195 | + } elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
207 | 196 | return 'enum(['.$enum[1].'])'; |
208 | - } |
|
209 | - else{ |
|
197 | + } else{ |
|
210 | 198 | return $column; |
211 | 199 | } |
212 | 200 | } |