@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | $schema = $this->compile(); |
79 | 79 | $absolutePath = Config::get('db-exporter.export_path.migrations'); |
80 | 80 | $this->makePath($absolutePath); |
81 | - $this->filename = date('Y_m_d_His').'_create_'.$this->database.'_database.php'; |
|
82 | - static::$filePath = $absolutePath."/{$this->filename}"; |
|
81 | + $this->filename = date('Y_m_d_His') . '_create_' . $this->database . '_database.php'; |
|
82 | + static::$filePath = $absolutePath . "/{$this->filename}"; |
|
83 | 83 | file_put_contents(static::$filePath, $schema); |
84 | 84 | |
85 | 85 | return static::$filePath; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $down = "Schema::drop('{$value['table_name']}');"; |
115 | - $up = "Schema::create('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
115 | + $up = "Schema::create('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
116 | 116 | |
117 | 117 | $tableDescribes = $this->getTableDescribes($value['table_name']); |
118 | 118 | // Loop over the tables fields |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | if (in_array($type, ['var', 'varchar', 'enum', 'decimal', 'float'])) { |
129 | 129 | $para = strpos($values->Type, '('); |
130 | 130 | $opt = substr($values->Type, ($para + 1), -1); |
131 | - $numbers = $type == 'enum' ? ', array('.$opt.')' : ', '.$opt; |
|
131 | + $numbers = $type == 'enum' ? ', array(' . $opt . ')' : ', ' . $opt; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $method = $this->columnType($type); |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | $method = 'increments'; |
137 | 137 | } |
138 | 138 | |
139 | - $up .= ' $'."table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
139 | + $up .= ' $' . "table->{$method}('{$values->Field}'{$numbers}){$nullable}{$default}{$unsigned};\n"; |
|
140 | 140 | }//end foreach |
141 | 141 | |
142 | 142 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
143 | 143 | if (!is_null($tableIndexes) && count($tableIndexes)) { |
144 | 144 | foreach ($tableIndexes as $index) { |
145 | 145 | if (Str::endsWith($index['Key_name'], '_index')) { |
146 | - $up .= ' $'."table->index('".$index['Column_name']."');\n"; |
|
146 | + $up .= ' $' . "table->index('" . $index['Column_name'] . "');\n"; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
157 | 157 | if (!is_null($tableConstraints) && count($tableConstraints)) { |
158 | 158 | $Constraint = $ConstraintDown = " |
159 | - Schema::table('{$value['table_name']}', function(Blueprint $"."table) {\n"; |
|
159 | + Schema::table('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
|
160 | 160 | $tables = []; |
161 | 161 | foreach ($tableConstraints as $foreign) { |
162 | 162 | if (!in_array($foreign->Field, $tables)) { |
163 | - $ConstraintDown .= ' $'."table->dropForeign('".$foreign->Field."');\n"; |
|
164 | - $Constraint .= ' $'."table->foreign('".$foreign->Field."')->references('".$foreign->References."')->on('".$foreign->ON."')->onDelete('".$foreign->onDelete."');\n"; |
|
163 | + $ConstraintDown .= ' $' . "table->dropForeign('" . $foreign->Field . "');\n"; |
|
164 | + $Constraint .= ' $' . "table->foreign('" . $foreign->Field . "')->references('" . $foreign->References . "')->on('" . $foreign->ON . "')->onDelete('" . $foreign->onDelete . "');\n"; |
|
165 | 165 | $tables[$foreign->Field] = $foreign->Field; |
166 | 166 | } |
167 | 167 | } |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | }//end if |
229 | 229 | |
230 | 230 | // Grab the template |
231 | - $template = File::get(__DIR__.'/stubs/migration.stub'); |
|
231 | + $template = File::get(__DIR__ . '/stubs/migration.stub'); |
|
232 | 232 | |
233 | 233 | // Replace the classname |
234 | - $template = str_replace('{{name}}', 'Create'.ucfirst(Str::camel($this->database)).'Database', $template); |
|
234 | + $template = str_replace('{{name}}', 'Create' . ucfirst(Str::camel($this->database)) . 'Database', $template); |
|
235 | 235 | |
236 | 236 | // Replace the up and down values |
237 | 237 | $template = str_replace('{{up}}', $upSchema, $template); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $pdo = DB::connection()->getPdo(); |
55 | 55 | |
56 | - return $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema="'.$this->database.'"'); |
|
56 | + return $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema="' . $this->database . '"'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | //end getTables() |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $pdo = DB::connection()->getPdo(); |
64 | 64 | |
65 | - return $pdo->query('SHOW INDEX FROM '.$this->database.'.'.$table.' WHERE Key_name != "PRIMARY"'); |
|
65 | + return $pdo->query('SHOW INDEX FROM ' . $this->database . '.' . $table . ' WHERE Key_name != "PRIMARY"'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | //end getTableIndexes() |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function getTableData($table) |
114 | 114 | { |
115 | - return DB::table($this->database.'.'.$table)->get(); |
|
115 | + return DB::table($this->database . '.' . $table)->get(); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | //end getTableData() |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $directories = explode($del, $path); |
130 | 130 | foreach ($directories as $directory) { |
131 | 131 | if (!empty($directory)) { |
132 | - $dir .= $del.$directory; |
|
132 | + $dir .= $del . $directory; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | if (!is_dir($dir)) { |