Add explicit pilot states
This commit is contained in:
@@ -87,6 +87,15 @@ class CreateSettingsTable extends Migration
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'order' => 31,
|
'order' => 31,
|
||||||
|
'name' => 'Auto Accept New Pilot',
|
||||||
|
'group' => 'pilots',
|
||||||
|
'key' => 'pilot.auto_accept',
|
||||||
|
'value' => true,
|
||||||
|
'type' => 'boolean',
|
||||||
|
'description' => 'Automatically accept a pilot when they register',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'order' => 32,
|
||||||
'name' => 'Pilot ID Length',
|
'name' => 'Pilot ID Length',
|
||||||
'group' => 'pilots',
|
'group' => 'pilots',
|
||||||
'key' => 'pilots.id_length',
|
'key' => 'pilots.id_length',
|
||||||
@@ -28,6 +28,7 @@ class CreateUsersTable extends Migration
|
|||||||
$table->unsignedBigInteger('flight_time')->default(0);
|
$table->unsignedBigInteger('flight_time')->default(0);
|
||||||
$table->decimal('balance', 19)->nullable();
|
$table->decimal('balance', 19)->nullable();
|
||||||
$table->string('timezone', 64)->nullable();
|
$table->string('timezone', 64)->nullable();
|
||||||
|
$table->unsignedTinyInteger('status')->default(0);
|
||||||
$table->boolean('active')->nullable();
|
$table->boolean('active')->nullable();
|
||||||
$table->rememberToken();
|
$table->rememberToken();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|||||||
@@ -16,6 +16,45 @@ use Illuminate\Support\Facades\Hash;
|
|||||||
class UserService extends BaseService
|
class UserService extends BaseService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a pilot
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function createPilot(array $data)
|
||||||
|
{
|
||||||
|
$opts = [
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'api_key' => Utils::generateApiKey(),
|
||||||
|
'airline_id' => $data['airline'],
|
||||||
|
'home_airport_id' => $data['home_airport'],
|
||||||
|
'curr_airport_id' => $data['home_airport'],
|
||||||
|
'password' => Hash::make($data['password'])
|
||||||
|
];
|
||||||
|
|
||||||
|
# Determine if we want to auto accept
|
||||||
|
if(setting('pilot.auto_accept') === true) {
|
||||||
|
$opts['status'] = config('enums.states.ACTIVE');
|
||||||
|
} else {
|
||||||
|
$opts['status'] = config('enums.states.PENDING');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = User::create($opts);
|
||||||
|
|
||||||
|
# Attach the user roles
|
||||||
|
$role = Role::where('name', 'user')->first();
|
||||||
|
$user->attachRole($role);
|
||||||
|
|
||||||
|
# Let's check their rank
|
||||||
|
$this->calculatePilotRank($user);
|
||||||
|
|
||||||
|
# TODO: Send out an email
|
||||||
|
event(new UserRegistered($user));
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
public function adjustFlightCount(User $user, int $count): User
|
public function adjustFlightCount(User $user, int $count): User
|
||||||
{
|
{
|
||||||
$user->refresh();
|
$user->refresh();
|
||||||
@@ -60,34 +99,4 @@ class UserService extends BaseService
|
|||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a pilot
|
|
||||||
* @param array $data
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function createPilot(array $data)
|
|
||||||
{
|
|
||||||
$user = User::create([
|
|
||||||
'name' => $data['name'],
|
|
||||||
'email' => $data['email'],
|
|
||||||
'api_key' => Utils::generateApiKey(),
|
|
||||||
'airline_id' => $data['airline'],
|
|
||||||
'home_airport_id' => $data['home_airport'],
|
|
||||||
'curr_airport_id' => $data['home_airport'],
|
|
||||||
'password' => Hash::make($data['password'])
|
|
||||||
]);
|
|
||||||
|
|
||||||
# Attach the user roles
|
|
||||||
$role = Role::where('name', 'user')->first();
|
|
||||||
$user->attachRole($role);
|
|
||||||
|
|
||||||
# Let's check their rank
|
|
||||||
$this->calculatePilotRank($user);
|
|
||||||
|
|
||||||
# TODO: Send out an email
|
|
||||||
event(new UserRegistered($user));
|
|
||||||
|
|
||||||
return $user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ return [
|
|||||||
'ENABLED' => 1,
|
'ENABLED' => 1,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
# Pilot states
|
||||||
|
'states' => [
|
||||||
|
'PENDING' => 0,
|
||||||
|
'ACTIVE' => 1,
|
||||||
|
'ON_LEAVE' => 2,
|
||||||
|
'SUSPENDED' => 3,
|
||||||
|
],
|
||||||
|
|
||||||
'sources' => [
|
'sources' => [
|
||||||
'MANUAL' => 0,
|
'MANUAL' => 0,
|
||||||
'ACARS' => 1,
|
'ACARS' => 1,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"/>
|
href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"/>
|
||||||
<!-- CSS Files -->
|
<!-- CSS Files -->
|
||||||
<link href="/assets/frontend/css/bootstrap.min.css" rel="stylesheet"/>
|
<link href="/assets/frontend/css/bootstrap.min.css" rel="stylesheet"/>
|
||||||
<link href="/vendor/select2/dist/css/select2.min.css" rel="stylesheet"/>
|
|
||||||
<link href="/assets/frontend/css/now-ui-kit.css" rel="stylesheet"/>
|
<link href="/assets/frontend/css/now-ui-kit.css" rel="stylesheet"/>
|
||||||
<link href="/assets/frontend/css/styles.css" rel="stylesheet"/>
|
<link href="/assets/frontend/css/styles.css" rel="stylesheet"/>
|
||||||
{{--<link href="/assets/frontend/css/installer.css" rel="stylesheet"/>--}}
|
{{--<link href="/assets/frontend/css/installer.css" rel="stylesheet"/>--}}
|
||||||
|
|||||||
Reference in New Issue
Block a user