Add explicit pilot states
This commit is contained in:
@@ -87,6 +87,15 @@ class CreateSettingsTable extends Migration
|
||||
],
|
||||
[
|
||||
'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',
|
||||
'group' => 'pilots',
|
||||
'key' => 'pilots.id_length',
|
||||
@@ -28,6 +28,7 @@ class CreateUsersTable extends Migration
|
||||
$table->unsignedBigInteger('flight_time')->default(0);
|
||||
$table->decimal('balance', 19)->nullable();
|
||||
$table->string('timezone', 64)->nullable();
|
||||
$table->unsignedTinyInteger('status')->default(0);
|
||||
$table->boolean('active')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
|
||||
@@ -16,6 +16,45 @@ use Illuminate\Support\Facades\Hash;
|
||||
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
|
||||
{
|
||||
$user->refresh();
|
||||
@@ -60,34 +99,4 @@ class UserService extends BaseService
|
||||
|
||||
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,
|
||||
],
|
||||
|
||||
# Pilot states
|
||||
'states' => [
|
||||
'PENDING' => 0,
|
||||
'ACTIVE' => 1,
|
||||
'ON_LEAVE' => 2,
|
||||
'SUSPENDED' => 3,
|
||||
],
|
||||
|
||||
'sources' => [
|
||||
'MANUAL' => 0,
|
||||
'ACARS' => 1,
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css"/>
|
||||
<!-- CSS Files -->
|
||||
<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/styles.css" rel="stylesheet"/>
|
||||
{{--<link href="/assets/frontend/css/installer.css" rel="stylesheet"/>--}}
|
||||
|
||||
Reference in New Issue
Block a user