Skip to content

Conversation

@arthurpar06
Copy link
Member

In v7, we had code to dispatch events when a user's state or rank was updated from the admin panel. This feature was forgotten during the migration to v8, and this PR restores it.

This pull request introduces event-driven updates to the EditUser page in the UserResource to handle state and rank changes. Key changes include the addition of event triggers, new private properties for tracking old values, and lifecycle hooks for saving operations.

Event-driven updates:

  • Added UserStateChanged and UserStatsChanged event imports to handle state and rank change notifications. (app/Filament/Resources/UserResource/Pages/EditUser.php)
  • Introduced private properties $oldState and $oldRankId to store the user's previous state and rank ID for comparison during save operations. (app/Filament/Resources/UserResource/Pages/EditUser.php)
  • Added beforeSave and afterSave lifecycle hooks:
    • beforeSave: Captures the user's current state and rank ID before saving.
    • afterSave: Triggers UserStateChanged and UserStatsChanged events if the state or rank ID has changed. (app/Filament/Resources/UserResource/Pages/EditUser.php)

@nabeelio nabeelio merged commit f18b2a8 into phpvms:main May 9, 2025
6 checks passed
@arthurpar06 arthurpar06 deleted the fix/userEvents branch May 9, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants