don't change rank if it's not auto promoted #168

This commit is contained in:
Nabeel Shahzad
2018-02-10 17:53:25 -06:00
parent 2a289e0468
commit 762544ea6f

View File

@@ -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();