diff --git a/app/Events/UserStatsChanged.php b/app/Events/UserStatsChanged.php index 9c5cf973..d74a22c7 100644 --- a/app/Events/UserStatsChanged.php +++ b/app/Events/UserStatsChanged.php @@ -17,6 +17,7 @@ class UserStatsChanged /* * When a user's stats change. Stats changed match the field name: + * airport * flights * rank */ diff --git a/app/Services/PIREPService.php b/app/Services/PIREPService.php index a4d2770d..ca9be39d 100644 --- a/app/Services/PIREPService.php +++ b/app/Services/PIREPService.php @@ -198,10 +198,11 @@ class PIREPService extends BaseService $pilot = $pirep->pilot; $pilot->refresh(); + $previous_airport = $pilot->curr_airport_id; $pilot->curr_airport_id = $pirep->arr_airport_id; $pilot->last_pirep_id = $pirep->id; $pilot->save(); - event(new UserStatsChanged($pilot)); + event(new UserStatsChanged($pilot, 'airport', $previous_airport)); } } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 7fb153b2..9dfb24a5 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -54,7 +54,7 @@ class UserService extends BaseService public function changeUserState(User $user, $old_state): User { if($user->state === $old_state) { - return; + return $user; } Log::info('User ' . $user->pilot_id . ' state changing from '