@@ 33-47 (lines=15) @@ | ||
30 | $table->timestamps(); |
|
31 | }); |
|
32 | ||
33 | Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
34 | $table->unsignedInteger('permission_id'); |
|
35 | ||
36 | $table->string('model_type'); |
|
37 | $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
38 | $table->index([$columnNames['model_morph_key'], 'model_type', ]); |
|
39 | ||
40 | $table->foreign('permission_id') |
|
41 | ->references('id') |
|
42 | ->on($tableNames['permissions']) |
|
43 | ->onDelete('cascade'); |
|
44 | ||
45 | $table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'], |
|
46 | 'model_has_permissions_permission_model_type_primary'); |
|
47 | }); |
|
48 | ||
49 | Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
50 | $table->unsignedInteger('role_id'); |
|
@@ 49-63 (lines=15) @@ | ||
46 | 'model_has_permissions_permission_model_type_primary'); |
|
47 | }); |
|
48 | ||
49 | Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) { |
|
50 | $table->unsignedInteger('role_id'); |
|
51 | ||
52 | $table->string('model_type'); |
|
53 | $table->unsignedBigInteger($columnNames['model_morph_key']); |
|
54 | $table->index([$columnNames['model_morph_key'], 'model_type', ]); |
|
55 | ||
56 | $table->foreign('role_id') |
|
57 | ->references('id') |
|
58 | ->on($tableNames['roles']) |
|
59 | ->onDelete('cascade'); |
|
60 | ||
61 | $table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'], |
|
62 | 'model_has_roles_role_model_type_primary'); |
|
63 | }); |
|
64 | ||
65 | Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { |
|
66 | $table->unsignedInteger('permission_id'); |