Passed
Push — master ( 3f0190...dc4c90 )
by Andrey
10:32
created

BaseMigration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A schema() 0 4 1
A rename() 0 3 1
A drop() 0 3 1
A create() 0 3 1
A table() 0 3 1
1
<?php
2
3
namespace Helldar\Roles\Support\Database;
4
5
use Closure;
6
use Helldar\Roles\Facades\Config;
7
use Illuminate\Database\Migrations\Migration;
8
use Illuminate\Database\Schema\Builder;
9
use Illuminate\Support\Facades\Schema;
10
11
abstract class BaseMigration extends Migration
12
{
13
    protected $roles = 'roles';
14
15
    protected $permissions = 'permissions';
16
17
    protected $user_roles = 'user_roles';
18
19
    protected $user_role = 'user_role';
20
21
    protected $role_permissions = 'role_permissions';
22
23
    protected $role_permission = 'role_permission';
24
25
    protected $users = 'users';
26
27
    abstract public function up();
28
29
    abstract public function down();
30
31
    protected function schema(): Builder
32
    {
33
        return Schema::connection(
34
            Config::connection()
35
        );
36
    }
37
38
    protected function create(string $table, Closure $callback)
39
    {
40
        $this->schema()->create($table, $callback);
41
    }
42
43
    protected function drop(string $table)
44
    {
45
        $this->schema()->dropIfExists($table);
46
    }
47
48
    protected function table(string $table, Closure $callback)
49
    {
50
        $this->schema()->table($table, $callback);
51
    }
52
53
    protected function rename(string $from, string $to)
54
    {
55
        $this->schema()->rename($from, $to);
56
    }
57
}
58