From 4488b7821f19ad23d9a4621680968f03b3fcd899 Mon Sep 17 00:00:00 2001 From: a6a2f5842 Date: Thu, 31 Jul 2025 17:03:41 +0200 Subject: [PATCH] A role expiration --- src/Traits/HasRoles.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Traits/HasRoles.php b/src/Traits/HasRoles.php index d627a1d..39cdfc8 100644 --- a/src/Traits/HasRoles.php +++ b/src/Traits/HasRoles.php @@ -19,7 +19,10 @@ trait HasRoles config('roles.models.role', \Blax\Roles\Models\Role::class), 'member', config('roles.table_names.role_members', 'role_members') - ); + )->withPivot('expires_at', 'created_at', 'updated_at') + ->withTimestamps() + ->wherePivot('expires_at', '>', now()) + ->orWhereNull('expires_at'); } /**