@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | $schema = $this->compile(); |
109 | 109 | $absolutePath = Config::get('db-exporter.export_path.migrations'); |
110 | 110 | $this->makePath($absolutePath); |
111 | - $this->filename = date('Y_m_d_His').'_create_'.$this->database.'_database.php'; |
|
112 | - static::$filePath = $absolutePath."/{$this->filename}"; |
|
111 | + $this->filename = date('Y_m_d_His') . '_create_' . $this->database . '_database.php'; |
|
112 | + static::$filePath = $absolutePath . "/{$this->filename}"; |
|
113 | 113 | file_put_contents(static::$filePath, $schema); |
114 | 114 | |
115 | 115 | return static::$filePath; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | $down = "Schema::dropIfExists('{$value['table_name']}');"; |
145 | - $up = "Schema::create('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
145 | + $up = "Schema::create('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
146 | 146 | |
147 | 147 | $tableDescribes = $this->getTableDescribes($value['table_name']); |
148 | 148 | // Loop over the tables fields |
@@ -162,15 +162,15 @@ discard block |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - $up .= ' $'."table->{$this->methodName}('{$values->Field}'{$this->defaultLength}){$this->primaryKey}{$nullable}{$default}{$unsigned};\n"; |
|
165 | + $up .= ' $' . "table->{$this->methodName}('{$values->Field}'{$this->defaultLength}){$this->primaryKey}{$nullable}{$default}{$unsigned};\n"; |
|
166 | 166 | $this->unsetData(); |
167 | 167 | }//end foreach |
168 | 168 | |
169 | - $tableIndexes = (array) $this->getTableIndexes($value['table_name']); |
|
169 | + $tableIndexes = (array)$this->getTableIndexes($value['table_name']); |
|
170 | 170 | if (!is_null($tableIndexes) && count($tableIndexes)) { |
171 | 171 | foreach ($tableIndexes as $index) { |
172 | 172 | if (Str::endsWith(@$index['Key_name'], '_index')) { |
173 | - $up .= ' $'."table->index('".$index['Column_name']."');\n"; |
|
173 | + $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
184 | 184 | if (!is_null($tableConstraints) && $tableConstraints->count()) { |
185 | 185 | $Constraint = $ConstraintDown = " |
186 | - Schema::table('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
186 | + Schema::table('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
187 | 187 | $tables = []; |
188 | 188 | foreach ($tableConstraints as $foreign) { |
189 | 189 | if (!in_array($foreign->Field, $tables)) { |
190 | 190 | $field = "{$foreign->Table}_{$foreign->Field}_foreign"; |
191 | - $ConstraintDown .= ' $'."table->dropForeign('".$field."');\n"; |
|
192 | - $Constraint .= ' $'."table->foreign('".$foreign->Field."')->references('".$foreign->References."')->on('".$foreign->ON."')->onDelete('".$foreign->onDelete."');\n"; |
|
191 | + $ConstraintDown .= ' $' . "table->dropForeign('" . $field . "');\n"; |
|
192 | + $Constraint .= ' $' . "table->foreign('" . $foreign->Field . "')->references('" . $foreign->References . "')->on('" . $foreign->ON . "')->onDelete('" . $foreign->onDelete . "');\n"; |
|
193 | 193 | $tables[$foreign->Field] = $foreign->Field; |
194 | 194 | } |
195 | 195 | } |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | }//end if |
257 | 257 | |
258 | 258 | // Grab the template |
259 | - $template = File::get(__DIR__.'/stubs/migration.stub'); |
|
259 | + $template = File::get(__DIR__ . '/stubs/migration.stub'); |
|
260 | 260 | |
261 | 261 | // Replace the classname |
262 | - $template = str_replace('{{name}}', 'Create'.ucfirst(Str::camel($this->database)).'Database', $template); |
|
262 | + $template = str_replace('{{name}}', 'Create' . ucfirst(Str::camel($this->database)) . 'Database', $template); |
|
263 | 263 | |
264 | 264 | // Replace the up and down values |
265 | 265 | $template = str_replace('{{up}}', $upSchema, $template); |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | if ($hasSize = strpos($column->Type, '(')) { |
281 | 281 | $values = substr($column->Type, ($hasSize + 1), -1); |
282 | 282 | if ('enum' == $type) { |
283 | - $this->defaultLength = ', array('.$values.')'; |
|
283 | + $this->defaultLength = ', array(' . $values . ')'; |
|
284 | 284 | } elseif (in_array($type, ['char', 'varchar', 'text', 'mediumtext', 'longtext'])) { |
285 | - $this->defaultLength = ', '.$column->Length; |
|
285 | + $this->defaultLength = ', ' . $column->Length; |
|
286 | 286 | } elseif (in_array($type, ['double', 'float', 'decimal'])) { |
287 | 287 | $this->defaultLength = ", $column->Precision, $column->Scale"; |
288 | 288 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | * @var array |
28 | 28 | **/ |
29 | 29 | protected $selects = [ |
30 | - 'column_name as Field', |
|
31 | - 'column_type as Type', |
|
32 | - 'is_nullable as Nullable', |
|
33 | - 'column_key as Key', |
|
34 | - 'column_default as Default', |
|
35 | - 'extra as Extra', |
|
36 | - 'data_type as Data_Type', |
|
37 | - 'CHARACTER_MAXIMUM_LENGTH as Length', |
|
38 | - 'NUMERIC_PRECISION as Precision', |
|
39 | - 'NUMERIC_SCALE as Scale', |
|
40 | - ]; |
|
30 | + 'column_name as Field', |
|
31 | + 'column_type as Type', |
|
32 | + 'is_nullable as Nullable', |
|
33 | + 'column_key as Key', |
|
34 | + 'column_default as Default', |
|
35 | + 'extra as Extra', |
|
36 | + 'data_type as Data_Type', |
|
37 | + 'CHARACTER_MAXIMUM_LENGTH as Length', |
|
38 | + 'NUMERIC_PRECISION as Precision', |
|
39 | + 'NUMERIC_SCALE as Scale', |
|
40 | + ]; |
|
41 | 41 | /** |
42 | 42 | * Select fields from constraints. |
43 | 43 | * |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | { |
57 | 57 | $pdo = DB::connection()->getPdo(); |
58 | 58 | |
59 | - return $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema="'.$this->database.'"'); |
|
59 | + return $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema="' . $this->database . '"'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public function getTableIndexes($table) |
63 | 63 | { |
64 | 64 | $pdo = DB::connection()->getPdo(); |
65 | 65 | |
66 | - return $pdo->query('SHOW INDEX FROM '.$this->database.'.'.$table.' WHERE Key_name != "PRIMARY"'); |
|
66 | + return $pdo->query('SHOW INDEX FROM ' . $this->database . '.' . $table . ' WHERE Key_name != "PRIMARY"'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | protected function getTableData($table) |
109 | 109 | { |
110 | - return DB::table($this->database.'.'.$table)->get(); |
|
110 | + return DB::table($this->database . '.' . $table)->get(); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $directories = explode($del, $path); |
123 | 123 | foreach ($directories as $directory) { |
124 | 124 | if (!empty($directory)) { |
125 | - $dir .= $del.$directory; |
|
125 | + $dir .= $del . $directory; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | if (!is_dir($dir)) { |