Passed
Push — master ( 3398a6...8ef8c3 )
by Jeremy
05:53
created

CreateRolesTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 5 1
A up() 0 15 2
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreateRolesTable extends Migration
8
{
9
    /**
10
     * Run the migrations.
11
     *
12
     * @return void
13
     */
14
    public function up()
15
    {
16
        $connection = config('roles.connection');
17
        $table = config('roles.rolesTable');
18
        $tableCheck = Schema::connection($connection)->hasTable($table);
19
20
        if (!$tableCheck) {
21
            Schema::connection($connection)->create($table, function (Blueprint $table) {
22
                $table->increments('id')->unsigned();
23
                $table->string('name');
24
                $table->string('slug')->unique();
25
                $table->string('description')->nullable();
26
                $table->integer('level')->default(1);
27
                $table->timestamps();
28
                $table->softDeletes();
29
            });
30
        }
31
    }
32
33
    /**
34
     * Reverse the migrations.
35
     *
36
     * @return void
37
     */
38
    public function down()
39
    {
40
        $connection = config('roles.connection');
41
        $table = config('roles.rolesTable');
42
        Schema::connection($connection)->dropIfExists($table);
43
    }
44
}
45