diff --git a/app/Database/seeds/settings.yml b/app/Database/seeds/settings.yml index 2d301cde..69304ff3 100644 --- a/app/Database/seeds/settings.yml +++ b/app/Database/seeds/settings.yml @@ -180,3 +180,10 @@ options: '' type: boolean description: 'Restrict flights to the user''s airline' +- key: pilots.allow_transfer_hours + name: 'Allow transfer hours' + group: pilots + value: true + options: '' + type: boolean + description: 'Allow specifying transfer hours on registration page and displayed on profile page' diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 5419460b..2d97f5d3 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -237,6 +237,9 @@ class UserController extends Controller $original_user_state = $user->state; + // Convert transferred hours to minutes + $req_data['transfer_time'] = $req_data['transfer_time'] * 60; + $user = $this->userRepo->update($req_data, $id); if ($original_user_state !== $user->state) { diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 9658b14b..8626a147 100755 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -115,6 +115,11 @@ class RegisterController extends Controller $opts['curr_airport_id'] = $data['home_airport_id']; $opts['password'] = Hash::make($data['password']); + // Convert transfer hours into minutes + if (isset($opts['transfer_time'])) { + $opts['transfer_time'] = $opts['transfer_time'] * 60; + } + $user = User::create($opts); $user = $this->userService->createPilot($user); @@ -142,6 +147,7 @@ class RegisterController extends Controller 'password' => 'required|confirmed', 'timezone' => 'required', 'country' => 'required', + 'transfer_time' => 'integer|min:0', ]; if (config('captcha.enabled')) { diff --git a/app/Models/User.php b/app/Models/User.php index fcace333..f5dfaaaa 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -57,7 +57,7 @@ class User extends Authenticatable 'last_pirep_id', 'flights', 'flight_time', - 'transferred_time', + 'transfer_time', 'avatar', 'timezone', 'state', @@ -79,7 +79,7 @@ class User extends Authenticatable protected $casts = [ 'flights' => 'integer', 'flight_time' => 'integer', - 'transferred_time' => 'integer', + 'transfer_time' => 'integer', 'balance' => 'double', 'state' => 'integer', 'status' => 'integer', diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index 39f32de9..71d9cf9f 100755 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -20,4 +20,5 @@ return [ 'deniedmessage' => 'Your registration was denied. Please contact an administrator.', 'accountsuspended' => 'Account Suspended', 'suspendedmessage' => 'Your account has been suspended. Please contact an administrator.', + 'transferhours' => 'Transfer Hours', ]; diff --git a/resources/lang/en/profile.php b/resources/lang/en/profile.php index 552c7771..9c7be356 100644 --- a/resources/lang/en/profile.php +++ b/resources/lang/en/profile.php @@ -14,4 +14,5 @@ return [ 'updateprofile' => 'Update Profile', 'editprofile' => 'Edit Profile', 'edityourprofile' => 'Edit Your Profile', + 'transferhours' => 'Transferred Hours', ]; diff --git a/resources/lang/it/auth.php b/resources/lang/it/auth.php index 08aa103f..1799fccc 100644 --- a/resources/lang/it/auth.php +++ b/resources/lang/it/auth.php @@ -20,4 +20,5 @@ return [ 'deniedmessage' => 'La tua registrazione è stata rifiutata. Contatta un amministratore per favore.', 'accountsuspended' => 'Account Sospeso', 'suspendedmessage' => 'Il tuo account è stato sospeso. Contatta un amministratore per favore.', + 'transferhours' => 'Ore di trasferimento', ]; diff --git a/resources/lang/it/profile.php b/resources/lang/it/profile.php index 2380ddbd..196553d9 100644 --- a/resources/lang/it/profile.php +++ b/resources/lang/it/profile.php @@ -13,4 +13,5 @@ return [ 'updateprofile' => 'Aggiorna Profilo', 'editprofile' => 'Modifica Profilo', 'edityourprofile' => 'Modifica Il Tuo Profilo', + 'transferhours' => 'Ore trasferite', ]; diff --git a/resources/views/admin/users/fields.blade.php b/resources/views/admin/users/fields.blade.php index d9806d92..42255d70 100644 --- a/resources/views/admin/users/fields.blade.php +++ b/resources/views/admin/users/fields.blade.php @@ -30,6 +30,11 @@ {{ Form::select('timezone', $timezones, null, ['id' => 'timezone', 'class' => 'select2' ]) }}

{{ $errors->first('timezone') }}

+
+ {{ Form::label('transfer_time', 'Transferred Hours:') }} + {{ Form::text('transfer_time', \App\Facades\Utils::minutesToHours($user->transfer_time), ['class' => 'form-control']) }} +

{{ $errors->first('transfer_time') }}

+
{{ Form::label('home_airport_id', 'Home Airport:') }} diff --git a/resources/views/layouts/default/auth/register.blade.php b/resources/views/layouts/default/auth/register.blade.php index 424a44af..c2b563e3 100644 --- a/resources/views/layouts/default/auth/register.blade.php +++ b/resources/views/layouts/default/auth/register.blade.php @@ -59,6 +59,16 @@

{{ $errors->first('timezone') }}

@endif + @if (setting('pilots.allow_transfer_hours') === true) + +
+ {{ Form::text('transfer_time', 0, ['class' => 'form-control']) }} +
+ @if ($errors->has('transfer_time')) +

{{ $errors->first('transfer_time') }}

+ @endif + @endif +
{{ Form::password('password', ['class' => 'form-control']) }} diff --git a/resources/views/layouts/default/profile/index.blade.php b/resources/views/layouts/default/profile/index.blade.php index 37194856..6b7eab02 100644 --- a/resources/views/layouts/default/profile/index.blade.php +++ b/resources/views/layouts/default/profile/index.blade.php @@ -45,6 +45,13 @@
@endif + @if(setting('pilots.allow_transfer_hours') === true) +
+

{{ \App\Facades\Utils::minutesToHours($user->transfer_time) }}h

+

@lang('profile.transferhours')

+
+ @endif +