@@ -103,18 +103,18 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
| 105 | 105 | if (!is_null($tableIndexes) && count($tableIndexes)){ |
| 106 | - foreach ($tableIndexes as $index) { |
|
| 106 | + foreach ($tableIndexes as $index) { |
|
| 107 | 107 | if(Str::endsWith($index['Key_name'], '_index')) { |
| 108 | - $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
| 108 | + $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | $up .= " });\n\n"; |
| 114 | 114 | $Constraint = $ConstraintDown = ""; |
| 115 | 115 | /** |
| 116 | - * @var array $tableConstraints |
|
| 117 | - */ |
|
| 116 | + * @var array $tableConstraints |
|
| 117 | + */ |
|
| 118 | 118 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
| 119 | 119 | if (!is_null($tableConstraints) && count($tableConstraints)) { |
| 120 | 120 | $Constraint = $ConstraintDown = " |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | public function columnType($type) |
| 145 | 145 | { |
| 146 | - $columns = ['int'=> 'integer','smallint' => 'smallInteger','bigint' => 'bigInteger','char '=>'string', 'varchar' => 'string','float' => 'float','double' => 'double','decimal' => 'decimal','tinyint' => 'boolean','date' => 'date','timestamp' => 'timestamp','datetime' => 'dateTime','longtext' => 'longText','mediumtext' => 'mediumText','text' => 'text','longblob' => 'binary' ,'blob' => 'binary','enum' => 'enum']; |
|
| 147 | - return array_key_exists($type, $columns) ? $columns[$type] : ''; |
|
| 146 | + $columns = ['int'=> 'integer','smallint' => 'smallInteger','bigint' => 'bigInteger','char '=>'string', 'varchar' => 'string','float' => 'float','double' => 'double','decimal' => 'decimal','tinyint' => 'boolean','date' => 'date','timestamp' => 'timestamp','datetime' => 'dateTime','longtext' => 'longText','mediumtext' => 'mediumText','text' => 'text','longblob' => 'binary' ,'blob' => 'binary','enum' => 'enum']; |
|
| 147 | + return array_key_exists($type, $columns) ? $columns[$type] : ''; |
|
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | $numbers = ""; |
| 86 | 86 | $nullable = $values->Null == "NO" ? "" : "->nullable()"; |
| 87 | 87 | $default = empty($values->Default) ? "" : "->default(\"{$values->Default}\")"; |
| 88 | - $default= $values->Default =='CURRENT_TIMESTAMP' ? '->useCurrent()':$default; |
|
| 89 | - $unsigned = strpos($values->Type, "unsigned") === false ? '': '->unsigned()'; |
|
| 88 | + $default = $values->Default == 'CURRENT_TIMESTAMP' ? '->useCurrent()' : $default; |
|
| 89 | + $unsigned = strpos($values->Type, "unsigned") === false ? '' : '->unsigned()'; |
|
| 90 | 90 | |
| 91 | 91 | if (in_array($type, ['var', 'varchar', 'enum', 'decimal', 'float'])) { |
| 92 | 92 | $para = strpos($values->Type, '('); |
| 93 | 93 | $opt = substr($values->Type, $para + 1, -1); |
| 94 | - $numbers = $type== 'enum' ? ', array(' . $opt . ')' : ", " .$opt; |
|
| 94 | + $numbers = $type == 'enum' ? ', array(' . $opt . ')' : ", " . $opt; |
|
| 95 | 95 | } |
| 96 | 96 | $method = $this->columnType($type); |
| 97 | 97 | if ($values->Key == 'PRI') { |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
| 105 | - if (!is_null($tableIndexes) && count($tableIndexes)){ |
|
| 105 | + if (!is_null($tableIndexes) && count($tableIndexes)) { |
|
| 106 | 106 | foreach ($tableIndexes as $index) { |
| 107 | - if(Str::endsWith($index['Key_name'], '_index')) { |
|
| 107 | + if (Str::endsWith($index['Key_name'], '_index')) { |
|
| 108 | 108 | $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | public function columnType($type) |
| 145 | 145 | { |
| 146 | - $columns = ['int'=> 'integer','smallint' => 'smallInteger','bigint' => 'bigInteger','char '=>'string', 'varchar' => 'string','float' => 'float','double' => 'double','decimal' => 'decimal','tinyint' => 'boolean','date' => 'date','timestamp' => 'timestamp','datetime' => 'dateTime','longtext' => 'longText','mediumtext' => 'mediumText','text' => 'text','longblob' => 'binary' ,'blob' => 'binary','enum' => 'enum']; |
|
| 146 | + $columns = ['int'=> 'integer', 'smallint' => 'smallInteger', 'bigint' => 'bigInteger', 'char '=>'string', 'varchar' => 'string', 'float' => 'float', 'double' => 'double', 'decimal' => 'decimal', 'tinyint' => 'boolean', 'date' => 'date', 'timestamp' => 'timestamp', 'datetime' => 'dateTime', 'longtext' => 'longText', 'mediumtext' => 'mediumText', 'text' => 'text', 'longblob' => 'binary', 'blob' => 'binary', 'enum' => 'enum']; |
|
| 147 | 147 | return array_key_exists($type, $columns) ? $columns[$type] : ''; |
| 148 | 148 | |
| 149 | 149 | |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | * Table: {$name} |
| 174 | 174 | */ |
| 175 | 175 | {$values['up']}"; |
| 176 | - $upConstraint.=" |
|
| 176 | + $upConstraint .= " |
|
| 177 | 177 | {$values['constraint']}"; |
| 178 | - $downConstraint.=" |
|
| 178 | + $downConstraint .= " |
|
| 179 | 179 | {$values['constraint_down']}"; |
| 180 | 180 | |
| 181 | 181 | $downSchema .= " |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | public function getTableIndexes($table) |
| 55 | 55 | { |
| 56 | 56 | $pdo = DB::connection()->getPdo(); |
| 57 | - return $pdo->query('SHOW INDEX FROM ' .$this->database.'.'. $table . ' WHERE Key_name != "PRIMARY"'); |
|
| 57 | + return $pdo->query('SHOW INDEX FROM ' . $this->database . '.' . $table . ' WHERE Key_name != "PRIMARY"'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |