From 762544ea6fbeb378f7342dc50740d295700076f4 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sat, 10 Feb 2018 17:53:25 -0600 Subject: [PATCH] don't change rank if it's not auto promoted #168 --- app/Services/UserService.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 104c2c7c..a74d570f 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -148,11 +148,17 @@ class UserService extends BaseService public function calculatePilotRank(User $user): User { $user->refresh(); + + # If their current rank is one they were assigned, then + # don't change away from it automatically. + if($user->rank->auto_promote === false) { + return $user; + } + $old_rank = $user->rank; $original_rank_id = $user->rank_id; $pilot_hours = Utils::minutesToHours($user->flight_time); - # TODO: Cache $ranks = Rank::where('auto_promote', true) ->orderBy('hours', 'asc')->get();