CreatePcmmMenusTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 24
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Support\Facades\Artisan;
4
use Illuminate\Support\Facades\Schema;
5
use Illuminate\Database\Schema\Blueprint;
6
use PhpCollective\MenuMaker\Storage\Menu;
7
use Illuminate\Database\Migrations\Migration;
8
9
class CreatePcmmMenusTable extends Migration
10
{
11
    /**
12
     * Run the migrations.
13
     *
14
     * @return void
15
     */
16
    public function up()
17
    {
18
        Schema::create('pcmm_menus', function (Blueprint $table) {
19
            $table->increments('id');
20
            $table->nestedSet();
21
            $table->string('name', 100);
22
            $table->string('alias', 100)->unique();
23
            $table->json('routes')->nullable();
24
            $table->string('link', 255)->nullable();
25
            $table->string('icon', 100)->nullable();
26
            $table->string('class', 100)->nullable();
27
            $table->string('attr', 100)->nullable();
28
            $table->unsignedInteger('position')->default(0);
29
            $table->enum('privilege', ['PUBLIC', 'PROTECTED', 'PRIVATE'])->default(Menu::DEFAULT_PRIVILAGE);
30
            $table->boolean('visible')->default(true);
31
            $table->timestamps();
32
33
            $table->foreign('parent_id')->references('id')->on('pcmm_menus')->onDelete('restrict');
34
35
        });
36
37
        Artisan::call('db:seed', [
38
            '--class' => PcmmMenusTableSeeder::class,
39
            '--force'   => true
40
        ]);
41
42
    }
43
44
    /**
45
     * Reverse the migrations.
46
     *
47
     * @return void
48
     */
49
    public function down()
50
    {
51
        Schema::dropIfExists('pcmm_menus');
52
    }
53
}
54