Completed
Push — master ( 3d9eaa...7212f9 )
by Stephen
35:45
created

CreatePermissionUserTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 40
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
class CreatePermissionUserTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        Schema::create('permission_' . str_singular(config('laravel-acl.authTable')), function (Blueprint $table) {
17
            $table->increments('id');
18
            $table->integer('permission_id')->unsigned();
19
            $table->integer(str_singular(config('laravel-acl.authTable')) . '_id')->unsigned();
20
            $table->boolean('negated')->default(false);
21
            $table->timestamps();
22
23
            $table->index('permission_id');
24
            $table->index(str_singular(config('laravel-acl.authTable')) . '_id');
25
            $table->index('negated');
26
27
            $table->foreign('permission_id')->references('id')->on('permissions');
28
            $table->foreign(str_singular(config('laravel-acl.authTable')) . '_id')->references('id')->on(config('laravel-acl.authTable'));
29
        });
30
    }
31
32
    /**
33
     * Reverse the migrations.
34
     *
35
     * @return void
36
     */
37
    public function down()
38
    {
39
        Schema::table('permission_' . str_singular(config('laravel-acl.authTable')), function (Blueprint $table) {
40
            $table->dropForeign(['permission_id']);
41
            $table->dropForeign([str_singular(config('laravel-acl.authTable')) . '_id']);
42
        });
43
44
        Schema::dropIfExists('permission_' . str_singular(config('laravel-acl.authTable')));
45
    }
46
}
47