pull/324/head
Nabeel Shahzad 5 years ago
parent 3e1d9080df
commit 80560ec20c

@ -1,10 +1,9 @@
<?php
use App\Contracts\Model;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UsersAddPilotId extends Migration
{

@ -107,7 +107,7 @@ class User extends Authenticatable
{
$length = setting('pilots.id_length');
return $this->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);
}
/**

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

@ -1,6 +1,5 @@
<?php
use App\Models\Airport;
use App\Models\User;
use App\Repositories\SettingRepository;
use App\Services\UserService;
@ -192,6 +191,7 @@ class UserTest extends TestCase
/**
* Test the pilot ID being added when a new user is created
*
* @expectedException \App\Exceptions\UserPilotIdExists
*/
public function testUserPilotIdChangeAlreadyExists()

Loading…
Cancel
Save