CreateRolePermissionTable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
c 0
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 9 1
A down() 0 3 1
1
<?php
2
3
use Illuminate\Support\Facades\Schema;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Database\Migrations\Migration;
6
7
/**
8
 * Class CreateRolePermissionTable
9
 *
10
 * @author Andrey Girnik <[email protected]>
11
 */
12
class CreateRolePermissionTable extends Migration
13
{
14
    /**
15
     * Run the migrations.
16
     * @return void
17
     */
18
    public function up()
19
    {
20
        Schema::create('role_permission', function (Blueprint $table) {
21
            $table->unsignedInteger('role_id');
22
            $table->unsignedInteger('permission_id');
23
            $table->timestamps();
24
            $table->unique(['permission_id','role_id']);
25
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
26
            $table->foreign('permission_id')->references('id')->on('permissions')->onDelete('cascade');
27
        });
28
    }
29
30
    /**
31
     * Reverse the migrations.
32
     * @return void
33
     */
34
    public function down()
35
    {
36
        Schema::dropIfExists('role_permission');
37
    }
38
}
39