Passed
Push — master ( 4688c8...2d21c0 )
by Andrey
12:30
created

BaseMigration::createPivot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 5
dl 0
loc 10
ccs 0
cts 0
cp 0
crap 2
rs 10
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 $permissions = 'permissions';
14
15
    protected $role_permission = 'role_permission';
16
17
    protected $role_permissions = 'role_permissions';
18
19
    protected $roles = 'roles';
20
21
    protected $user_permission = 'user_permission';
22
23
    protected $user_role = 'user_role';
24
25
    protected $user_roles = 'user_roles';
26
27
    protected $users = 'users';
28
29
    abstract public function up();
30
31 42
    abstract public function down();
32
33 42
    protected function schema(): Builder
34 42
    {
35
        return Schema::connection(
36
            Config::connection()
37
        );
38 42
    }
39
40 42
    protected function create(string $table, Closure $callback)
41 42
    {
42
        $this->schema()->create($table, $callback);
43
    }
44
45
    protected function drop(string $table)
46
    {
47
        $this->schema()->dropIfExists($table);
48 42
    }
49
50 42
    protected function table(string $table, Closure $callback)
51 42
    {
52
        $this->schema()->table($table, $callback);
53 42
    }
54
55 42
    protected function rename(string $from, string $to)
56 42
    {
57
        $this->schema()->rename($from, $to);
58
    }
59
60
    protected function dropTables(...$tables)
61
    {
62
        foreach ($tables as $table) {
63
            $this->drop($table);
64
        }
65
    }
66
}
67