@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $schema = $this->compile(); |
74 | 74 | $absolutePath = Config::get('db-exporter.export_path.migrations'); |
75 | 75 | $this->makePath($absolutePath); |
76 | - $this->filename = date('Y_m_d_His').'_create_'.$this->database.'_database.php'; |
|
77 | - static::$filePath = $absolutePath."/{$this->filename}"; |
|
76 | + $this->filename = date('Y_m_d_His') . '_create_' . $this->database . '_database.php'; |
|
77 | + static::$filePath = $absolutePath . "/{$this->filename}"; |
|
78 | 78 | file_put_contents(static::$filePath, $schema); |
79 | 79 | |
80 | 80 | return static::$filePath; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $down = "Schema::drop('{$value['table_name']}');"; |
110 | - $up = "Schema::create('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
110 | + $up = "Schema::create('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
111 | 111 | |
112 | 112 | $tableDescribes = $this->getTableDescribes($value['table_name']); |
113 | 113 | // Loop over the tables fields |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if (in_array($type, ['var', 'varchar', 'enum', 'decimal', 'float'])) { |
124 | 124 | $para = strpos($values->Type, '('); |
125 | 125 | $opt = substr($values->Type, ($para + 1), -1); |
126 | - $numbers = $type == 'enum' ? ', array('.$opt.')' : ', '.$opt; |
|
126 | + $numbers = $type == 'enum' ? ', array(' . $opt . ')' : ', ' . $opt; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $method = $this->columnType($type); |
@@ -131,14 +131,14 @@ discard block |
||
131 | 131 | $method = 'increments'; |
132 | 132 | } |
133 | 133 | |
134 | - $up .= ' $'."table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
134 | + $up .= ' $' . "table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
135 | 135 | }//end foreach |
136 | 136 | |
137 | 137 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
138 | 138 | if (!is_null($tableIndexes) && count($tableIndexes)) { |
139 | 139 | foreach ($tableIndexes as $index) { |
140 | 140 | if (Str::endsWith($index['Key_name'], '_index')) { |
141 | - $up .= ' $'."table->index('".$index['Column_name']."');\n"; |
|
141 | + $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
152 | 152 | if (!is_null($tableConstraints) && count($tableConstraints)) { |
153 | 153 | $Constraint = $ConstraintDown = " |
154 | - Schema::table('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
154 | + Schema::table('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
155 | 155 | $tables = []; |
156 | 156 | foreach ($tableConstraints as $foreign) { |
157 | 157 | if (!in_array($foreign->Field, $tables)) { |
158 | - $ConstraintDown .= ' $'."table->dropForeign('".$foreign->Field."');\n"; |
|
159 | - $Constraint .= ' $'."table->foreign('".$foreign->Field."')->references('".$foreign->References."')->on('".$foreign->ON."')->onDelete('".$foreign->onDelete."');\n"; |
|
158 | + $ConstraintDown .= ' $' . "table->dropForeign('" . $foreign->Field . "');\n"; |
|
159 | + $Constraint .= ' $' . "table->foreign('" . $foreign->Field . "')->references('" . $foreign->References . "')->on('" . $foreign->ON . "')->onDelete('" . $foreign->onDelete . "');\n"; |
|
160 | 160 | $tables[$foreign->Field] = $foreign->Field; |
161 | 161 | } |
162 | 162 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | - $upSchema .= " |
|
209 | + $upSchema .= " |
|
210 | 210 | /** |
211 | 211 | * Migration schema for table {$name} |
212 | 212 | * |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | }//end if |
224 | 224 | |
225 | 225 | // Grab the template |
226 | - $template = File::get(__DIR__.'/stubs/migration.stub'); |
|
226 | + $template = File::get(__DIR__ . '/stubs/migration.stub'); |
|
227 | 227 | |
228 | 228 | // Replace the classname |
229 | - $template = str_replace('{{name}}', 'Create'.ucfirst(Str::camel($this->database)).'Database', $template); |
|
229 | + $template = str_replace('{{name}}', 'Create' . ucfirst(Str::camel($this->database)) . 'Database', $template); |
|
230 | 230 | |
231 | 231 | // Replace the up and down values |
232 | 232 | $template = str_replace('{{up}}', $upSchema, $template); |