Formatting
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Contracts\Model;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
|
|
||||||
class UsersAddPilotId extends Migration
|
class UsersAddPilotId extends Migration
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ class User extends Authenticatable
|
|||||||
{
|
{
|
||||||
$length = setting('pilots.id_length');
|
$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->pilot_id = $max + 1;
|
||||||
$user->save();
|
$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;
|
return $user;
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ class UserService extends Service
|
|||||||
* Change a user's pilot ID
|
* Change a user's pilot ID
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param int $pilot_id
|
* @param int $pilot_id
|
||||||
*
|
*
|
||||||
* @throws UserPilotIdExists
|
* @throws UserPilotIdExists
|
||||||
*
|
*
|
||||||
@@ -122,6 +122,7 @@ class UserService extends Service
|
|||||||
{
|
{
|
||||||
if (User::where('pilot_id', '=', $pilot_id)->exists()) {
|
if (User::where('pilot_id', '=', $pilot_id)->exists()) {
|
||||||
Log::error('User with id '.$pilot_id.' already exists');
|
Log::error('User with id '.$pilot_id.' already exists');
|
||||||
|
|
||||||
throw new UserPilotIdExists();
|
throw new UserPilotIdExists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Airport;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\SettingRepository;
|
use App\Repositories\SettingRepository;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
@@ -192,6 +191,7 @@ class UserTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the pilot ID being added when a new user is created
|
* Test the pilot ID being added when a new user is created
|
||||||
|
*
|
||||||
* @expectedException \App\Exceptions\UserPilotIdExists
|
* @expectedException \App\Exceptions\UserPilotIdExists
|
||||||
*/
|
*/
|
||||||
public function testUserPilotIdChangeAlreadyExists()
|
public function testUserPilotIdChangeAlreadyExists()
|
||||||
|
|||||||
Reference in New Issue
Block a user