CreatePermissionsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
4
use Illuminate\Database\Schema\Blueprint;
5
use Illuminate\Support\Facades\Schema;
6
7
class CreatePermissionsTable 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.permissionsTable');
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->string('model')->nullable();
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.permissionsTable');
42
        Schema::connection($connection)->dropIfExists($table);
43
    }
44
}
45