Formatting

This commit is contained in:
Nabeel Shahzad
2019-07-16 14:06:13 -04:00
parent 3e1d9080df
commit 80560ec20c
4 changed files with 7 additions and 7 deletions
@@ -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
View File
@@ -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);
} }
/** /**
+3 -2
View File
@@ -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
View File
@@ -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()