Update expiry email to show pending role. if there is one

This commit is contained in:
DariusIII
2026-05-30 18:15:49 +02:00
parent 6e5940cd81
commit f8c52d176e
4 changed files with 61 additions and 2 deletions
+10 -1
View File
@@ -109,6 +109,7 @@ use Spatie\Permission\Traits\HasRoles;
* @property-read Collection<int, UserRoleHistory> $roleHistory
* @property-read Collection<int, Passkey> $passkeys
* @property-read Role|null $role
* @property-read Role|null $pendingRole
* @property-read PasswordSecurity|null $passwordSecurity
*
* @method static Builder|User whereUsername(string $value)
@@ -228,6 +229,14 @@ final class User extends Authenticatable implements HasPasskeys, MustVerifyEmail
return $this->belongsTo(Role::class, 'roles_id');
}
/**
* @return BelongsTo<Role, $this>
*/
public function pendingRole(): BelongsTo
{
return $this->belongsTo(Role::class, 'pending_roles_id');
}
/**
* @return HasMany<UserRequest, $this>
*/
@@ -649,7 +658,7 @@ final class User extends Authenticatable implements HasPasskeys, MustVerifyEmail
return null;
}
return Role::find($this->pending_roles_id);
return $this->pendingRole;
}
/**