1 | <?php |
||
2 | |||
3 | namespace Awssat\SyncMigration; |
||
4 | |||
5 | use Illuminate\Database\Schema\Blueprint; |
||
6 | use Illuminate\Support\Facades\Schema as LaravelSchema; |
||
7 | |||
8 | class Column |
||
9 | { |
||
10 | protected $schema; |
||
11 | |||
12 | /** |
||
13 | * Column constructor. |
||
14 | * @param $schema |
||
15 | */ |
||
16 | public function __construct(Schema $schema) |
||
17 | { |
||
18 | $this->schema = $schema; |
||
19 | } |
||
20 | |||
21 | |||
22 | public function create($line, $column) |
||
23 | { |
||
24 | LaravelSchema::table($this->schema->name, function (Blueprint $table) use ($line) { |
||
0 ignored issues
–
show
|
|||
25 | eval($line . ';'); |
||
26 | }); |
||
27 | |||
28 | $this->schema->output()->warn("New column <fg=black;bg=yellow> {$this->schema->name}->{$column[0]} </> was created"); |
||
29 | } |
||
30 | |||
31 | public function delete($column) |
||
32 | { |
||
33 | LaravelSchema::table($this->schema->name, function (Blueprint $table) use ($column) { |
||
34 | $table->dropColumn($column); |
||
35 | }); |
||
36 | |||
37 | $this->schema->output()->warn("Column <fg=black;bg=yellow> {$this->schema->name}->{$column} </> was deleted"); |
||
38 | } |
||
39 | |||
40 | public function rename($column) |
||
41 | { |
||
42 | $renameTo = $this->schema->output()->choice('Rename to ? :', $this->schema->schemaUnsyncedColumnsOutput(), 0); |
||
43 | |||
44 | LaravelSchema::table($this->schema->name, function (Blueprint $table) use ($column, $renameTo) { |
||
45 | $table->renameColumn($column, $renameTo); |
||
46 | }); |
||
47 | |||
48 | $this->schema->output()->warn("Column <fg=black;bg=yellow> {$this->schema->name}->{$column} </> was renamed to '{$renameTo}'"); |
||
49 | } |
||
50 | |||
51 | public function ignore($column) |
||
52 | { |
||
53 | $this->schema->output()->info("<fg=black;bg=yellow> {$this->schema->name}->{$column} </> was ignored"); |
||
54 | } |
||
55 | } |
||
56 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.