From 16ddfd10c306069ec75d0da5252c4633023aa282 Mon Sep 17 00:00:00 2001 From: Ahmad Afandi Date: Mon, 27 Oct 2025 11:51:03 +0700 Subject: [PATCH] Perbaikan install awal --- ..._06_08_015654_create_permission_tables.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/database/migrations/2023_06_08_015654_create_permission_tables.php b/database/migrations/2023_06_08_015654_create_permission_tables.php index 6f54fce1b..d3cbf07c0 100644 --- a/database/migrations/2023_06_08_015654_create_permission_tables.php +++ b/database/migrations/2023_06_08_015654_create_permission_tables.php @@ -51,13 +51,13 @@ public function up() }); Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); + $table->unsignedBigInteger($columnNames['permission_pivot_key'] ?? 'permission_id'); $table->string('model_type', 191); $table->unsignedBigInteger($columnNames['model_morph_key']); $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); - $table->foreign(PermissionRegistrar::$pivotPermission) + $table->foreign($columnNames['permission_pivot_key'] ?? 'permission_id') ->references('id') // permission id ->on($tableNames['permissions']) ->onDelete('cascade'); @@ -65,22 +65,22 @@ public function up() $table->unsignedBigInteger($columnNames['team_foreign_key']); $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); - $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + $table->primary([$columnNames['team_foreign_key'], $columnNames['permission_pivot_key'] ?? 'permission_id', $columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_permission_model_type_primary'); } else { - $table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + $table->primary([$columnNames['permission_pivot_key'] ?? 'permission_id', $columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_permission_model_type_primary'); } }); Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + $table->unsignedBigInteger($columnNames['role_pivot_key'] ?? 'role_id'); $table->string('model_type', 191); $table->unsignedBigInteger($columnNames['model_morph_key']); $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); - $table->foreign(PermissionRegistrar::$pivotRole) + $table->foreign($columnNames['role_pivot_key'] ?? 'role_id') ->references('id') // role id ->on($tableNames['roles']) ->onDelete('cascade'); @@ -88,29 +88,29 @@ public function up() $table->unsignedBigInteger($columnNames['team_foreign_key']); $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); - $table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], + $table->primary([$columnNames['team_foreign_key'], $columnNames['role_pivot_key'] ?? 'role_id', $columnNames['model_morph_key'], 'model_type'], 'model_has_roles_role_model_type_primary'); } else { - $table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'], + $table->primary([$columnNames['role_pivot_key'] ?? 'role_id', $columnNames['model_morph_key'], 'model_type'], 'model_has_roles_role_model_type_primary'); } }); - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { - $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); - $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) { + $table->unsignedBigInteger($columnNames['permission_pivot_key'] ?? 'permission_id'); + $table->unsignedBigInteger($columnNames['role_pivot_key'] ?? 'role_id'); - $table->foreign(PermissionRegistrar::$pivotPermission) + $table->foreign($columnNames['permission_pivot_key'] ?? 'permission_id') ->references('id') // permission id ->on($tableNames['permissions']) ->onDelete('cascade'); - $table->foreign(PermissionRegistrar::$pivotRole) + $table->foreign($columnNames['role_pivot_key'] ?? 'role_id') ->references('id') // role id ->on($tableNames['roles']) ->onDelete('cascade'); - $table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + $table->primary([$columnNames['permission_pivot_key'] ?? 'permission_id', $columnNames['role_pivot_key'] ?? 'role_id'], 'role_has_permissions_permission_id_role_id_primary'); }); app('cache')