ModifyRolesAndPermissionsTablesAddTitleColumn   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 4 1
A down() 0 4 1
A dropTitleColumn() 0 4 1
A addTitleColumn() 0 4 1
1
<?php
2
3
use Helldar\Roles\Support\Database\BaseMigration;
4
use Illuminate\Database\Schema\Blueprint;
5
6
class ModifyRolesAndPermissionsTablesAddTitleColumn extends BaseMigration
7
{
8
    public function up()
9
    {
10
        $this->addTitleColumn($this->roles);
11
        $this->addTitleColumn($this->permissions);
12
    }
13
14
    public function down()
15
    {
16
        $this->dropTitleColumn($this->roles);
17
        $this->dropTitleColumn($this->permissions);
18
    }
19
20
    protected function addTitleColumn(string $table): void
21
    {
22
        $this->table($table, function (Blueprint $table) {
23
            $table->string('title')->nullable()->after('slug');
24
        });
25
    }
26
27
    protected function dropTitleColumn(string $table): void
28
    {
29
        $this->table($table, function (Blueprint $table) {
30
            $table->dropColumn('title');
31
        });
32
    }
33
}
34