Total Complexity | 3 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class CreateRolesTable extends Migration |
||
9 | { |
||
10 | /** |
||
11 | * Run the migrations. |
||
12 | * |
||
13 | * @return void |
||
14 | */ |
||
15 | public function up() |
||
16 | { |
||
17 | Schema::create('roles', function (Blueprint $table) { |
||
18 | $table->id(); |
||
19 | $table->string('name'); |
||
20 | $table->text('description')->nullable(); |
||
21 | $table->integer('level')->default(0); |
||
22 | $table->timestamps(); |
||
23 | }); |
||
24 | |||
25 | // Migrate with dummy |
||
26 | if (config('adminetic.migrate_with_dummy', false)) { |
||
27 | $roles = [ |
||
28 | [ |
||
29 | 'name' => 'superadmin', |
||
30 | 'description' => 'This is a super admin user', |
||
31 | 'level' => 5, |
||
32 | ], |
||
33 | [ |
||
34 | 'name' => 'admin', |
||
35 | 'description' => 'This is an admin user', |
||
36 | 'level' => 4, |
||
37 | ], |
||
38 | [ |
||
39 | 'name' => 'moderator', |
||
40 | 'description' => 'This is an moderator', |
||
41 | 'level' => 3, |
||
42 | ], |
||
43 | [ |
||
44 | 'name' => 'editor', |
||
45 | 'description' => 'This is an editor', |
||
46 | 'level' => 2, |
||
47 | ], |
||
48 | [ |
||
49 | 'name' => 'user', |
||
50 | 'description' => 'This is an normal user', |
||
51 | 'level' => 1, |
||
52 | ], |
||
53 | [ |
||
54 | 'name' => 'unverified', |
||
55 | 'description' => 'This is an unverified user', |
||
56 | 'level' => 0, |
||
57 | ], |
||
58 | ]; |
||
59 | |||
60 | DB::table('roles')->insert($roles); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Reverse the migrations. |
||
66 | * |
||
67 | * @return void |
||
68 | */ |
||
69 | public function down() |
||
72 | } |
||
73 | } |
||
74 |