1 | <?php |
||
7 | class CreatePermissionUserTable extends Migration |
||
8 | { |
||
9 | /** |
||
10 | * Run the migrations. |
||
11 | * |
||
12 | * @return void |
||
13 | */ |
||
14 | public function up() |
||
15 | { |
||
16 | Schema::create('permission_' . str_singular(config('laravel-acl.authTable')), function (Blueprint $table) { |
||
17 | $table->increments('id'); |
||
18 | $table->integer('permission_id')->unsigned(); |
||
19 | $table->integer(str_singular(config('laravel-acl.authTable')) . '_id')->unsigned(); |
||
20 | $table->boolean('negated')->default(false); |
||
21 | $table->timestamps(); |
||
22 | |||
23 | $table->index('permission_id'); |
||
24 | $table->index(str_singular(config('laravel-acl.authTable')) . '_id'); |
||
25 | $table->index('negated'); |
||
26 | |||
27 | $table->foreign('permission_id')->references('id')->on('permissions'); |
||
28 | $table->foreign(str_singular(config('laravel-acl.authTable')) . '_id')->references('id')->on(config('laravel-acl.authTable')); |
||
29 | }); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Reverse the migrations. |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public function down() |
||
38 | { |
||
39 | Schema::table('permission_' . str_singular(config('laravel-acl.authTable')), function (Blueprint $table) { |
||
40 | $table->dropForeign(['permission_id']); |
||
41 | $table->dropForeign([str_singular(config('laravel-acl.authTable')) . '_id']); |
||
42 | }); |
||
43 | |||
44 | Schema::dropIfExists('permission_' . str_singular(config('laravel-acl.authTable'))); |
||
45 | } |
||
46 | } |
||
47 |