Pilot changed event fixed for new airport
This commit is contained in:
@@ -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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 '
|
||||||
|
|||||||
Reference in New Issue
Block a user