From e423003a23a84f9b36fa6106f1b52c2a3a1d9cd9 Mon Sep 17 00:00:00 2001 From: Faizal Nugraha Date: Wed, 18 Sep 2024 01:40:15 +0700 Subject: [PATCH] remove pivot id --- app/Models/PermissionRole.php | 7 ------- app/Models/RoleUser.php | 7 ------- .../2024_09_13_032806_create_permission_tables.php | 6 ++---- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/app/Models/PermissionRole.php b/app/Models/PermissionRole.php index 6b74736..625b2e5 100644 --- a/app/Models/PermissionRole.php +++ b/app/Models/PermissionRole.php @@ -10,13 +10,6 @@ class PermissionRole extends Pivot { use LogsModel; - /** - * Indicates if the IDs are auto-incrementing. - * - * @var bool - */ - public $incrementing = true; - /** * Get the table associated with the model. * diff --git a/app/Models/RoleUser.php b/app/Models/RoleUser.php index a0bc84b..455911f 100644 --- a/app/Models/RoleUser.php +++ b/app/Models/RoleUser.php @@ -11,13 +11,6 @@ class RoleUser extends MorphPivot { use LogsModel; - /** - * Indicates if the IDs are auto-incrementing. - * - * @var bool - */ - public $incrementing = true; - /** * Get the table associated with the model. * diff --git a/database/migrations/2024_09_13_032806_create_permission_tables.php b/database/migrations/2024_09_13_032806_create_permission_tables.php index 16837f9..91fbf2e 100644 --- a/database/migrations/2024_09_13_032806_create_permission_tables.php +++ b/database/migrations/2024_09_13_032806_create_permission_tables.php @@ -77,7 +77,6 @@ public function up(): void }); Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) { - $table->bigIncrements('id'); $table->unsignedBigInteger($pivotRole); $table->string('model_type'); @@ -95,13 +94,12 @@ public function up(): void $table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], 'model_has_roles_role_model_type_primary'); } else { - $table->unique([$pivotRole, $columnNames['model_morph_key'], 'model_type'], + $table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'], 'model_has_roles_role_model_type_primary'); } }); Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) { - $table->bigIncrements('id'); $table->unsignedBigInteger($pivotPermission); $table->unsignedBigInteger($pivotRole); @@ -115,7 +113,7 @@ public function up(): void ->on($tableNames['roles']) ->onDelete('cascade'); - $table->unique([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + $table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); }); app('cache')