|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
5
|
|
|
|
|
6
|
|
|
class CreateAdminTables extends Migration |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* Run the migrations. |
|
10
|
|
|
* |
|
11
|
|
|
* @return void |
|
12
|
|
|
*/ |
|
13
|
|
|
public function up() |
|
14
|
|
|
{ |
|
15
|
|
|
Schema::create(config('admin.database.users_table'), function (Blueprint $table) { |
|
16
|
|
|
$table->increments('id'); |
|
17
|
|
|
$table->string('username', 190)->unique(); |
|
18
|
|
|
$table->string('password', 60); |
|
19
|
|
|
$table->string('name'); |
|
20
|
|
|
$table->string('remember_token', 100)->nullable(); |
|
21
|
|
|
$table->timestamps(); |
|
22
|
|
|
}); |
|
23
|
|
|
|
|
24
|
|
View Code Duplication |
Schema::create(config('admin.database.roles_table'), function (Blueprint $table) { |
|
|
|
|
|
|
25
|
|
|
$table->increments('id'); |
|
26
|
|
|
$table->string('name', 50)->unique(); |
|
27
|
|
|
$table->string('slug', 50); |
|
28
|
|
|
$table->timestamps(); |
|
29
|
|
|
}); |
|
30
|
|
|
|
|
31
|
|
View Code Duplication |
Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) { |
|
|
|
|
|
|
32
|
|
|
$table->increments('id'); |
|
33
|
|
|
$table->string('name', 50)->unique(); |
|
34
|
|
|
$table->string('slug', 50); |
|
35
|
|
|
$table->timestamps(); |
|
36
|
|
|
}); |
|
37
|
|
|
|
|
38
|
|
|
Schema::create(config('admin.database.menu_table'), function (Blueprint $table) { |
|
39
|
|
|
$table->increments('id'); |
|
40
|
|
|
$table->integer('parent_id')->default(0); |
|
41
|
|
|
$table->integer('order'); |
|
42
|
|
|
$table->string('title', 50); |
|
43
|
|
|
$table->string('icon', 50); |
|
44
|
|
|
$table->string('uri', 50); |
|
45
|
|
|
|
|
46
|
|
|
$table->timestamps(); |
|
47
|
|
|
}); |
|
48
|
|
|
|
|
49
|
|
View Code Duplication |
Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) { |
|
|
|
|
|
|
50
|
|
|
$table->integer('role_id'); |
|
51
|
|
|
$table->integer('user_id'); |
|
52
|
|
|
$table->index(['role_id', 'user_id']); |
|
53
|
|
|
$table->timestamps(); |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
View Code Duplication |
Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) { |
|
|
|
|
|
|
57
|
|
|
$table->integer('role_id'); |
|
58
|
|
|
$table->integer('permission_id'); |
|
59
|
|
|
$table->index(['role_id', 'permission_id']); |
|
60
|
|
|
$table->timestamps(); |
|
61
|
|
|
}); |
|
62
|
|
|
|
|
63
|
|
|
Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) { |
|
64
|
|
|
$table->integer('role_id'); |
|
65
|
|
|
$table->integer('menu_id'); |
|
66
|
|
|
$table->index(['role_id', 'menu_id']); |
|
67
|
|
|
$table->timestamps(); |
|
68
|
|
|
}); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Reverse the migrations. |
|
73
|
|
|
* |
|
74
|
|
|
* @return void |
|
75
|
|
|
*/ |
|
76
|
|
|
public function down() |
|
77
|
|
|
{ |
|
78
|
|
|
Schema::drop(config('admin.database.users_table')); |
|
79
|
|
|
Schema::drop(config('admin.database.roles_table')); |
|
80
|
|
|
Schema::drop(config('admin.database.permissions_table')); |
|
81
|
|
|
Schema::drop(config('admin.database.menu_table')); |
|
82
|
|
|
Schema::drop(config('admin.database.role_users_table')); |
|
83
|
|
|
Schema::drop(config('admin.database.role_permissions_table')); |
|
84
|
|
|
Schema::drop(config('admin.database.role_menu_table')); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.