@@ -63,7 +63,7 @@ |
||
63 | 63 | private function getFilename() |
64 | 64 | { |
65 | 65 | $filename = Str::camel($this->getDatabaseName()) . "TableSeeder"; |
66 | - return Config::get('db-exporter.export_path.seeds')."/{$filename}.php"; |
|
66 | + return Config::get('db-exporter.export_path.seeds') . "/{$filename}.php"; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | protected $name = 'db-exporter:remote'; |
14 | 14 | protected $description = 'Command to copy the migrations and/or the seeds to a remote host.'; |
15 | 15 | |
16 | - protected $ignoredFiles = array('..', '.', '.gitkeep'); |
|
16 | + protected $ignoredFiles = array('..', '.', '.gitkeep'); |
|
17 | 17 | |
18 | 18 | protected $migrationsPath; |
19 | 19 | protected $seedsPath; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | foreach ($this->uploadedFiles as $type => $files) { |
42 | 42 | $this->info(ucfirst($type)); |
43 | 43 | foreach ($files as $file) { |
44 | - $this->sectionMessage($type, $file .' uploaded.'); |
|
44 | + $this->sectionMessage($type, $file . ' uploaded.'); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -99,14 +99,14 @@ discard block |
||
99 | 99 | $localPath = "{$what}Path"; |
100 | 100 | |
101 | 101 | $dir = scandir($this->$localPath); |
102 | - $remotePath = Config::get('db-exporter.remote.'.$what); |
|
102 | + $remotePath = Config::get('db-exporter.remote.' . $what); |
|
103 | 103 | |
104 | 104 | // Prepare the progress bar |
105 | 105 | $progress = $this->getHelperSet()->get('progress'); |
106 | 106 | $filesCount = count($dir) - count($this->ignoredFiles); |
107 | 107 | $progress->start($this->output, $filesCount); |
108 | 108 | $this->info(ucfirst($what)); |
109 | - foreach($dir as $file) { |
|
109 | + foreach ($dir as $file) { |
|
110 | 110 | if (in_array($file, $this->ignoredFiles)) { |
111 | 111 | continue; |
112 | 112 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | // Copy the files |
118 | 118 | SSH::into($this->getRemoteName())->put( |
119 | - $this->$localPath .'/' . $file, |
|
119 | + $this->$localPath . '/' . $file, |
|
120 | 120 | $remotePath . $file |
121 | 121 | ); |
122 | 122 | $progress->advance(); |
@@ -79,7 +79,9 @@ |
||
79 | 79 | $options = $this->option(); |
80 | 80 | switch ($options) { |
81 | 81 | case (($options['seeds'] === true) && ($options['migrations'] === true)): |
82 | - if (!$this->upload('migrations')) return false; |
|
82 | + if (!$this->upload('migrations')) { |
|
83 | + return false; |
|
84 | + } |
|
83 | 85 | return $this->upload('seeds'); |
84 | 86 | break; |
85 | 87 | case $options['migrations'] === true: |
@@ -178,8 +178,9 @@ |
||
178 | 178 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
179 | 179 | if (!is_null($tableIndexes) && count($tableIndexes)){ |
180 | 180 | foreach ($tableIndexes as $index) { |
181 | - if(Str::endsWith($index['Key_name'], '_index')) |
|
182 | - $up .= ' $' . "table->index('" . $index['Key_name'] . "');\n"; |
|
181 | + if(Str::endsWith($index['Key_name'], '_index')) { |
|
182 | + $up .= ' $' . "table->index('" . $index['Key_name'] . "');\n"; |
|
183 | + } |
|
183 | 184 | } |
184 | 185 | } |
185 | 186 |
@@ -159,17 +159,17 @@ discard block |
||
159 | 159 | |
160 | 160 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
161 | 161 | if (!is_null($tableIndexes) && count($tableIndexes)){ |
162 | - foreach ($tableIndexes as $index) { |
|
162 | + foreach ($tableIndexes as $index) { |
|
163 | 163 | if(Str::endsWith($index['Key_name'], '_index')) |
164 | - $up .= ' $' . "table->index('" . $index['Key_name'] . "');\n"; |
|
164 | + $up .= ' $' . "table->index('" . $index['Key_name'] . "');\n"; |
|
165 | 165 | } |
166 | - } |
|
166 | + } |
|
167 | 167 | |
168 | 168 | $up .= " });\n\n"; |
169 | 169 | $Constraint = $ConstraintDown = ""; |
170 | 170 | /** |
171 | - * @var array $tableConstraints |
|
172 | - */ |
|
171 | + * @var array $tableConstraints |
|
172 | + */ |
|
173 | 173 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
174 | 174 | if (!is_null($tableConstraints) && count($tableConstraints)){ |
175 | 175 | $Constraint = $ConstraintDown = " |
@@ -210,24 +210,24 @@ discard block |
||
210 | 210 | |
211 | 211 | // prevent of failure when no table |
212 | 212 | if (!is_null($this->schema) && count($this->schema)) { |
213 | - foreach ($this->schema as $name => $values) { |
|
214 | - // check again for ignored tables |
|
215 | - if (in_array($name, self::$ignore)) { |
|
216 | - continue; |
|
217 | - } |
|
218 | - $upSchema .= " |
|
213 | + foreach ($this->schema as $name => $values) { |
|
214 | + // check again for ignored tables |
|
215 | + if (in_array($name, self::$ignore)) { |
|
216 | + continue; |
|
217 | + } |
|
218 | + $upSchema .= " |
|
219 | 219 | /** |
220 | 220 | * Table: {$name} |
221 | 221 | */ |
222 | 222 | {$values['up']}"; |
223 | 223 | $upConstraint.=" |
224 | 224 | {$values['constraint']}"; |
225 | - $downConstraint.=" |
|
225 | + $downConstraint.=" |
|
226 | 226 | {$values['constraint_down']}"; |
227 | 227 | |
228 | - $downSchema .= " |
|
228 | + $downSchema .= " |
|
229 | 229 | {$values['down']}"; |
230 | - } |
|
230 | + } |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // Grab the template |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | $schema = $this->compile(); |
46 | 46 | $filename = date('Y_m_d_His') . "_create_" . $this->database . "_database.php"; |
47 | - static::$filePath = Config::get('db-exporter.export_path.migrations')."{$filename}"; |
|
47 | + static::$filePath = Config::get('db-exporter.export_path.migrations') . "{$filename}"; |
|
48 | 48 | |
49 | 49 | file_put_contents(static::$filePath, $schema); |
50 | 50 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $numbers = ""; |
87 | 87 | $nullable = $values->Null == "NO" ? "" : "->nullable()"; |
88 | 88 | $default = empty($values->Default) ? "" : "->default(\"{$values->Default}\")"; |
89 | - $unsigned = strpos($values->Type, "unsigned") === false ? '': '->unsigned()'; |
|
89 | + $unsigned = strpos($values->Type, "unsigned") === false ? '' : '->unsigned()'; |
|
90 | 90 | |
91 | 91 | switch ($type) { |
92 | 92 | case 'int': |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | $tableIndexes = $this->getTableIndexes($value['table_name']); |
161 | - if (!is_null($tableIndexes) && count($tableIndexes)){ |
|
161 | + if (!is_null($tableIndexes) && count($tableIndexes)) { |
|
162 | 162 | foreach ($tableIndexes as $index) { |
163 | - if(Str::endsWith($index['Key_name'], '_index')) |
|
163 | + if (Str::endsWith($index['Key_name'], '_index')) |
|
164 | 164 | $up .= ' $' . "table->index('" . $index['Key_name'] . "');\n"; |
165 | 165 | } |
166 | 166 | } |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @var array $tableConstraints |
172 | 172 | */ |
173 | 173 | $tableConstraints = $this->getTableConstraints($value['table_name']); |
174 | - if (!is_null($tableConstraints) && count($tableConstraints)){ |
|
174 | + if (!is_null($tableConstraints) && count($tableConstraints)) { |
|
175 | 175 | $Constraint = $ConstraintDown = " |
176 | 176 | Schema::table('{$value['table_name']}', function(Blueprint $" . "table) {\n"; |
177 | 177 | $tables = []; |
178 | 178 | foreach ($tableConstraints as $foreign) { |
179 | - if(!in_array($foreign->Field, $tables)){ |
|
180 | - $ConstraintDown .= ' $' . "table->dropForeign('" . $foreign->Field. "');\n"; |
|
181 | - $Constraint .= ' $' . "table->foreign('" . $foreign->Field. "')->references('" . $foreign->References . "')->on('" . $foreign->ON. "')->onDelete('" . $foreign->onDelete. "');\n"; |
|
179 | + if (!in_array($foreign->Field, $tables)) { |
|
180 | + $ConstraintDown .= ' $' . "table->dropForeign('" . $foreign->Field . "');\n"; |
|
181 | + $Constraint .= ' $' . "table->foreign('" . $foreign->Field . "')->references('" . $foreign->References . "')->on('" . $foreign->ON . "')->onDelete('" . $foreign->onDelete . "');\n"; |
|
182 | 182 | $tables[$foreign->Field] = $foreign->Field; |
183 | 183 | } |
184 | 184 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * Table: {$name} |
221 | 221 | */ |
222 | 222 | {$values['up']}"; |
223 | - $upConstraint.=" |
|
223 | + $upConstraint .= " |
|
224 | 224 | {$values['constraint']}"; |
225 | - $downConstraint.=" |
|
225 | + $downConstraint .= " |
|
226 | 226 | {$values['constraint_down']}"; |
227 | 227 | |
228 | 228 | $downSchema .= " |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function register() |
31 | 31 | { |
32 | - $this->publishes([ |
|
32 | + $this->publishes([ |
|
33 | 33 | realpath(__DIR__ .'/../').'/config/db-exporter.php' => config_path('db-exporter.php'), |
34 | 34 | ]); |
35 | 35 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | realpath(__DIR__ .'/../').'/config/db-exporter.php', 'db-exporter' |
38 | 38 | ); |
39 | 39 | |
40 | - $this->app->register(DbMigrationsServiceProvider::class); |
|
40 | + $this->app->register(DbMigrationsServiceProvider::class); |
|
41 | 41 | |
42 | 42 | // Load the classes |
43 | 43 | $this->loadClasses(); |
@@ -38,11 +38,11 @@ |
||
38 | 38 | public function register() |
39 | 39 | { |
40 | 40 | $this->publishes([ |
41 | - realpath(__DIR__ .'/../').'/config/db-exporter.php' => config_path('db-exporter.php'), |
|
41 | + realpath(__DIR__ . '/../') . '/config/db-exporter.php' => config_path('db-exporter.php'), |
|
42 | 42 | ]); |
43 | 43 | |
44 | 44 | $this->mergeConfigFrom( |
45 | - realpath(__DIR__ .'/../').'/config/db-exporter.php', 'db-exporter' |
|
45 | + realpath(__DIR__ . '/../') . '/config/db-exporter.php', 'db-exporter' |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | $this->app->register(DbMigrationsServiceProvider::class); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $dir = scandir($localPath); |
23 | 23 | $remotePath = Config::get('db-exporter.remote.' . $what); |
24 | 24 | |
25 | - foreach($dir as $file) { |
|
25 | + foreach ($dir as $file) { |
|
26 | 26 | if (in_array($file, $this->ignoredFiles)) { |
27 | 27 | continue; |
28 | 28 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | // Copy the files |
34 | 34 | SSH::into($this->getRemoteName())->put( |
35 | - $localPath .'/' . $file, |
|
35 | + $localPath . '/' . $file, |
|
36 | 36 | $remotePath . $file |
37 | 37 | ); |
38 | 38 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $filename = Str::camel($this->database) . "TableSeeder"; |
47 | 47 | |
48 | - file_put_contents(Config::get('db-exporter.export_path.seeds')."/{$filename}.php", $seed); |
|
48 | + file_put_contents(Config::get('db-exporter.export_path.seeds') . "/{$filename}.php", $seed); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $value = addslashes($value); |
124 | 124 | if (is_numeric($value)) { |
125 | 125 | return " '{$prop}' => {$value},\n"; |
126 | - } elseif($value == '') { |
|
126 | + } elseif ($value == '') { |
|
127 | 127 | return " '{$prop}' => NULL,\n"; |
128 | 128 | } else { |
129 | 129 | return " '{$prop}' => '{$value}',\n"; |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $this->app->singleton('DbMigrations', function() |
35 | 35 | { |
36 | 36 | $connType = Config::get('database.default'); |
37 | - $database = Config::get('database.connections.' .$connType ); |
|
37 | + $database = Config::get('database.connections.' . $connType); |
|
38 | 38 | return new DbMigrations($database); |
39 | 39 | }); |
40 | 40 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | return DB::table('information_schema.key_column_usage') |
52 | 52 | ->distinct() |
53 | - ->join('information_schema.REFERENTIAL_CONSTRAINTS', 'REFERENTIAL_CONSTRAINTS.CONSTRAINT_NAME','=','key_column_usage.CONSTRAINT_NAME') |
|
53 | + ->join('information_schema.REFERENTIAL_CONSTRAINTS', 'REFERENTIAL_CONSTRAINTS.CONSTRAINT_NAME', '=', 'key_column_usage.CONSTRAINT_NAME') |
|
54 | 54 | ->where('key_column_usage.table_schema', '=', $this->database) |
55 | 55 | ->where('key_column_usage.table_name', '=', $table) |
56 | 56 | ->get($this->constraints); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function getTableData($table) |
65 | 65 | { |
66 | - return DB::table($this->database.'.'.$table)->get(); |
|
66 | + return DB::table($this->database . '.' . $table)->get(); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | protected function getDatabaseName() |
16 | 16 | { |
17 | 17 | $connType = Config::get('database.default'); |
18 | - $database = Config::get('database.connections.' .$connType ); |
|
18 | + $database = Config::get('database.connections.' . $connType); |
|
19 | 19 | |
20 | 20 | return $database['database']; |
21 | 21 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | - protected function fireAction($action,$database) |
|
55 | + protected function fireAction($action, $database) |
|
56 | 56 | { |
57 | 57 | // Grab the options |
58 | 58 | $ignore = $this->option('ignore'); |