@@ -15,25 +15,25 @@ discard block |
||
15 | 15 | * @var string |
16 | 16 | **/ |
17 | 17 | protected $columns = [ |
18 | - 'int' => 'integer', |
|
19 | - 'smallint' => 'smallInteger', |
|
20 | - 'bigint' => 'bigInteger', |
|
21 | - 'char ' => 'string', |
|
22 | - 'varchar' => 'string', |
|
23 | - 'float' => 'float', |
|
24 | - 'double' => 'double', |
|
25 | - 'decimal' => 'decimal', |
|
26 | - 'tinyint' => 'boolean', |
|
27 | - 'date' => 'date', |
|
28 | - 'timestamp' => 'timestamp', |
|
29 | - 'datetime' => 'dateTime', |
|
30 | - 'longtext' => 'longText', |
|
31 | - 'mediumtext' => 'mediumText', |
|
32 | - 'text' => 'text', |
|
33 | - 'longblob' => 'binary', |
|
34 | - 'blob' => 'binary', |
|
35 | - 'enum' => 'enum', |
|
36 | - ]; |
|
18 | + 'int' => 'integer', |
|
19 | + 'smallint' => 'smallInteger', |
|
20 | + 'bigint' => 'bigInteger', |
|
21 | + 'char ' => 'string', |
|
22 | + 'varchar' => 'string', |
|
23 | + 'float' => 'float', |
|
24 | + 'double' => 'double', |
|
25 | + 'decimal' => 'decimal', |
|
26 | + 'tinyint' => 'boolean', |
|
27 | + 'date' => 'date', |
|
28 | + 'timestamp' => 'timestamp', |
|
29 | + 'datetime' => 'dateTime', |
|
30 | + 'longtext' => 'longText', |
|
31 | + 'mediumtext' => 'mediumText', |
|
32 | + 'text' => 'text', |
|
33 | + 'longblob' => 'binary', |
|
34 | + 'blob' => 'binary', |
|
35 | + 'enum' => 'enum', |
|
36 | + ]; |
|
37 | 37 | /** |
38 | 38 | * Primary key column types. |
39 | 39 | * |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | $this->schema[$value['table_name']] = array( |
188 | - 'up' => $up, |
|
189 | - 'constraint' => $Constraint, |
|
190 | - 'constraint_down' => $ConstraintDown, |
|
191 | - 'down' => $down, |
|
192 | - ); |
|
188 | + 'up' => $up, |
|
189 | + 'constraint' => $Constraint, |
|
190 | + 'constraint_down' => $ConstraintDown, |
|
191 | + 'down' => $down, |
|
192 | + ); |
|
193 | 193 | }//end foreach |
194 | 194 | |
195 | 195 | return $this; |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $schema = $this->compile(); |
89 | 89 | $absolutePath = Config::get('db-exporter.export_path.migrations'); |
90 | 90 | $this->makePath($absolutePath); |
91 | - $this->filename = date('Y_m_d_His').'_create_'.$this->database.'_database.php'; |
|
92 | - static::$filePath = $absolutePath."/{$this->filename}"; |
|
91 | + $this->filename = date('Y_m_d_His') . '_create_' . $this->database . '_database.php'; |
|
92 | + static::$filePath = $absolutePath . "/{$this->filename}"; |
|
93 | 93 | file_put_contents(static::$filePath, $schema); |
94 | 94 | |
95 | 95 | return static::$filePath; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | $down = "Schema::drop('{$value['table_name']}');"; |
125 | - $up = "Schema::create('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
125 | + $up = "Schema::create('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
126 | 126 | |
127 | 127 | $tableDescribes = $this->getTableDescribes($value['table_name']); |
128 | 128 | // Loop over the tables fields |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | if (in_array($type, ['var', 'varchar', 'double', 'enum', 'decimal', 'float'])) { |
140 | 140 | $para = strpos($values->Type, '('); |
141 | 141 | $opt = substr($values->Type, ($para + 1), -1); |
142 | - $numbers = $type == 'enum' ? ', array('.$opt.')' : ', '.$opt; |
|
142 | + $numbers = $type == 'enum' ? ', array(' . $opt . ')' : ', ' . $opt; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $method = $this->columnType($type); |
146 | 146 | if ($values->Key == 'PRI') { |
147 | 147 | $tmp = $this->columnType($values->Data_Type, 'primaryKeys'); |
148 | 148 | $method = empty($tmp) ? $method : $tmp; |
149 | - $pri .= empty($tmp) ? ' $'."table->primary('".$values->Field."');\n" : ''; |
|
149 | + $pri .= empty($tmp) ? ' $' . "table->primary('" . $values->Field . "');\n" : ''; |
|
150 | 150 | } |
151 | 151 | |
152 | - $up .= ' $'."table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
152 | + $up .= ' $' . "table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
153 | 153 | $up .= $pri; |
154 | 154 | }//end foreach |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | if (!is_null($tableIndexes) && count($tableIndexes)) { |
158 | 158 | foreach ($tableIndexes as $index) { |
159 | 159 | if (Str::endsWith($index['Key_name'], '_index')) { |
160 | - $up .= ' $'."table->index('".$index['Column_name']."');\n"; |
|
160 | + $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
171 | 171 | if (!is_null($tableConstraints) && count($tableConstraints)) { |
172 | 172 | $Constraint = $ConstraintDown = " |
173 | - Schema::table('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
173 | + Schema::table('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
174 | 174 | $tables = []; |
175 | 175 | foreach ($tableConstraints as $foreign) { |
176 | 176 | if (!in_array($foreign->Field, $tables)) { |
177 | - $ConstraintDown .= ' $'."table->dropForeign('".$foreign->Field."');\n"; |
|
178 | - $Constraint .= ' $'."table->foreign('".$foreign->Field."')->references('".$foreign->References."')->on('".$foreign->ON."')->onDelete('".$foreign->onDelete."');\n"; |
|
177 | + $ConstraintDown .= ' $' . "table->dropForeign('" . $foreign->Field . "');\n"; |
|
178 | + $Constraint .= ' $' . "table->foreign('" . $foreign->Field . "')->references('" . $foreign->References . "')->on('" . $foreign->ON . "')->onDelete('" . $foreign->onDelete . "');\n"; |
|
179 | 179 | $tables[$foreign->Field] = $foreign->Field; |
180 | 180 | } |
181 | 181 | } |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | }//end if |
243 | 243 | |
244 | 244 | // Grab the template |
245 | - $template = File::get(__DIR__.'/stubs/migration.stub'); |
|
245 | + $template = File::get(__DIR__ . '/stubs/migration.stub'); |
|
246 | 246 | |
247 | 247 | // Replace the classname |
248 | - $template = str_replace('{{name}}', 'Create'.ucfirst(Str::camel($this->database)).'Database', $template); |
|
248 | + $template = str_replace('{{name}}', 'Create' . ucfirst(Str::camel($this->database)) . 'Database', $template); |
|
249 | 249 | |
250 | 250 | // Replace the up and down values |
251 | 251 | $template = str_replace('{{up}}', $upSchema, $template); |