@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function create($line, $column) |
23 | 23 | { |
24 | - LaravelSchema::table($this->schema->name, function (Blueprint $table) use ($line) { |
|
24 | + LaravelSchema::table($this->schema->name, function(Blueprint $table) use ($line) { |
|
25 | 25 | eval($line . ';'); |
26 | 26 | }); |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function delete($column) |
32 | 32 | { |
33 | - LaravelSchema::table($this->schema->name, function (Blueprint $table) use ($column) { |
|
33 | + LaravelSchema::table($this->schema->name, function(Blueprint $table) use ($column) { |
|
34 | 34 | $table->dropColumn($column); |
35 | 35 | }); |
36 | 36 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $renameTo = $this->schema->output()->choice('Rename to ? :', $this->schema->schemaUnsyncedColumnsOutput(), 0); |
43 | 43 | |
44 | - LaravelSchema::table($this->schema->name, function (Blueprint $table) use ($column, $renameTo) { |
|
44 | + LaravelSchema::table($this->schema->name, function(Blueprint $table) use ($column, $renameTo) { |
|
45 | 45 | $table->renameColumn($column, $renameTo); |
46 | 46 | }); |
47 | 47 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function register() |
15 | 15 | { |
16 | - $this->app->singleton('command.devMigrateCommand', function ($app) { |
|
16 | + $this->app->singleton('command.devMigrateCommand', function($app) { |
|
17 | 17 | return new SyncMigrateCommand($app['migrator']); |
18 | 18 | }); |
19 | 19 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->processMigration(file_get_contents($file)); |
59 | 59 | } |
60 | 60 | |
61 | - $this->abondedTables()->each(function ($table) { |
|
61 | + $this->abondedTables()->each(function($table) { |
|
62 | 62 | $this->error("Schemas doesn't have table <fg=black;bg=white> {$table} </> seems you have delete it"); |
63 | 63 | |
64 | 64 | $this->confirm("Do you want to drop <fg=black;bg=white> {$table} </> ?", |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | protected function tables() |
76 | 76 | { |
77 | - return collect(DB::select('SHOW TABLES'))->map(function ($table) { |
|
77 | + return collect(DB::select('SHOW TABLES'))->map(function($table) { |
|
78 | 78 | return array_values((array)$table); |
79 | 79 | })->flatten(); |
80 | 80 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | protected function schemasTables() |
107 | 107 | { |
108 | - return $this->schemas->pluck('name')->push('migrations')->map(function ($name) { |
|
108 | + return $this->schemas->pluck('name')->push('migrations')->map(function($name) { |
|
109 | 109 | return DB::getTablePrefix() . $name; |
110 | 110 | }); |
111 | 111 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | |
44 | 44 | protected function create() |
45 | 45 | { |
46 | - if($this->columnsList()->isEmpty()) { |
|
46 | + if ($this->columnsList()->isEmpty()) { |
|
47 | 47 | return $this->output()->error("Table <fg=black;bg=white> {$this->table} </> does not have any columns"); |
48 | 48 | } |
49 | 49 | |
50 | - LaravelSchema::create($this->name, function (Blueprint $table) { |
|
50 | + LaravelSchema::create($this->name, function(Blueprint $table) { |
|
51 | 51 | eval($this->schema->group(2)); |
52 | 52 | }); |
53 | 53 | |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | |
57 | 57 | protected function sync() |
58 | 58 | { |
59 | - if($this->schemaEmpty()) { |
|
59 | + if ($this->schemaEmpty()) { |
|
60 | 60 | return $this->dropSchema(); |
61 | 61 | } |
62 | 62 | |
63 | - $this->dbUnsyncedColumns()->each(function ($type, $column) { |
|
63 | + $this->dbUnsyncedColumns()->each(function($type, $column) { |
|
64 | 64 | $this->output()->info("Column <fg=black;bg=yellow> {$this->table}->{$column} </> is renamed or deleted !!"); |
65 | 65 | $action = $this->output()->choice('What we should do ?', $this->syncChoices(), 0); |
66 | 66 | |
67 | 67 | (new Column($this))->$action($column); |
68 | 68 | }); |
69 | 69 | |
70 | - $this->schemaUnsyncedColumns()->each(function ($column, $line) { |
|
70 | + $this->schemaUnsyncedColumns()->each(function($column, $line) { |
|
71 | 71 | (new Column($this))->create($line, $column); |
72 | 72 | }); |
73 | 73 | } |
@@ -96,38 +96,37 @@ discard block |
||
96 | 96 | |
97 | 97 | protected function dbUnsyncedColumns() |
98 | 98 | { |
99 | - return $this->dbColumns()->reject(function ($type, $column) { |
|
99 | + return $this->dbColumns()->reject(function($type, $column) { |
|
100 | 100 | return $this->columnsList()->values()->flatten()->contains($column); |
101 | 101 | }); |
102 | 102 | } |
103 | 103 | |
104 | 104 | protected function schemaUnsyncedColumns() |
105 | 105 | { |
106 | - return $this->columnsList()->reject(function ($column) { |
|
106 | + return $this->columnsList()->reject(function($column) { |
|
107 | 107 | return $this->dbColumns()->has($column); |
108 | 108 | }); |
109 | 109 | } |
110 | 110 | |
111 | 111 | protected function syncChoices() |
112 | 112 | { |
113 | - return $this->schemaUnsyncedColumns()->isEmpty() ? ['Delete', 'Ignore'] : |
|
114 | - ['Delete', 'Rename', 'Ignore']; |
|
113 | + return $this->schemaUnsyncedColumns()->isEmpty() ? ['Delete', 'Ignore'] : ['Delete', 'Rename', 'Ignore']; |
|
115 | 114 | } |
116 | 115 | |
117 | 116 | protected function dbColumns() |
118 | 117 | { |
119 | 118 | return collect(DB::select('DESCRIBE ' . $this->table)) |
120 | - ->mapWithKeys(function ($column) { |
|
119 | + ->mapWithKeys(function($column) { |
|
121 | 120 | return [$column->Field => $column->Type]; |
122 | 121 | }); |
123 | 122 | } |
124 | 123 | |
125 | 124 | protected function columnsList() |
126 | 125 | { |
127 | - return collect(explode(';', $this->schema->group(2)))->mapWithKeys(function ($line) { |
|
126 | + return collect(explode(';', $this->schema->group(2)))->mapWithKeys(function($line) { |
|
128 | 127 | $line = trim($line); |
129 | 128 | |
130 | - if(starts_with($line, ['//', '#', '/*'])) { |
|
129 | + if (starts_with($line, ['//', '#', '/*'])) { |
|
131 | 130 | return []; |
132 | 131 | } |
133 | 132 |