diff --git a/app/Database/migrations/2019_07_16_141152_users_add_pilot_id.php b/app/Database/migrations/2019_07_16_141152_users_add_pilot_id.php index 45500ef6..29ad73a4 100644 --- a/app/Database/migrations/2019_07_16_141152_users_add_pilot_id.php +++ b/app/Database/migrations/2019_07_16_141152_users_add_pilot_id.php @@ -1,10 +1,9 @@ airline->icao . str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT); + return $this->airline->icao.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT); } /** diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 145fb384..7c91ca0f 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -103,7 +103,7 @@ class UserService extends Service $user->pilot_id = $max + 1; $user->save(); - Log::info('Set pilot ID for user ' . $user->id . ' to ' . $user->pilot_id); + Log::info('Set pilot ID for user '.$user->id.' to '.$user->pilot_id); return $user; } @@ -112,7 +112,7 @@ class UserService extends Service * Change a user's pilot ID * * @param User $user - * @param int $pilot_id + * @param int $pilot_id * * @throws UserPilotIdExists * @@ -122,6 +122,7 @@ class UserService extends Service { if (User::where('pilot_id', '=', $pilot_id)->exists()) { Log::error('User with id '.$pilot_id.' already exists'); + throw new UserPilotIdExists(); } diff --git a/tests/UserTest.php b/tests/UserTest.php index 9e47cec1..374f49f6 100644 --- a/tests/UserTest.php +++ b/tests/UserTest.php @@ -1,6 +1,5 @@