Pilot changed event fixed for new airport

This commit is contained in:
Nabeel Shahzad
2017-12-22 16:55:47 -06:00
parent babdca627e
commit b382ad77eb
3 changed files with 4 additions and 2 deletions
+1
View File
@@ -17,6 +17,7 @@ class UserStatsChanged
/* /*
* When a user's stats change. Stats changed match the field name: * When a user's stats change. Stats changed match the field name:
* airport
* flights * flights
* rank * rank
*/ */
+2 -1
View File
@@ -198,10 +198,11 @@ class PIREPService extends BaseService
$pilot = $pirep->pilot; $pilot = $pirep->pilot;
$pilot->refresh(); $pilot->refresh();
$previous_airport = $pilot->curr_airport_id;
$pilot->curr_airport_id = $pirep->arr_airport_id; $pilot->curr_airport_id = $pirep->arr_airport_id;
$pilot->last_pirep_id = $pirep->id; $pilot->last_pirep_id = $pirep->id;
$pilot->save(); $pilot->save();
event(new UserStatsChanged($pilot)); event(new UserStatsChanged($pilot, 'airport', $previous_airport));
} }
} }
+1 -1
View File
@@ -54,7 +54,7 @@ class UserService extends BaseService
public function changeUserState(User $user, $old_state): User public function changeUserState(User $user, $old_state): User
{ {
if($user->state === $old_state) { if($user->state === $old_state) {
return; return $user;
} }
Log::info('User ' . $user->pilot_id . ' state changing from ' Log::info('User ' . $user->pilot_id . ' state changing from '