From 9253d398480623ffe74f103dc6bdd9c7244ad2b6 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Tue, 8 Feb 2022 01:47:57 +0300 Subject: [PATCH] Custom Code for Pilot IDents (#1398) * Custom Code for Pilot IDents Adds a new setting to customize the ident or to use a fixed icao code in a multi airline environment. If settings is null/empty, airline icao will be used as like before. * StyleFix --- app/Database/seeds/settings.yml | 7 +++++++ app/Models/User.php | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Database/seeds/settings.yml b/app/Database/seeds/settings.yml index 6d4c0e4b..24a87b32 100644 --- a/app/Database/seeds/settings.yml +++ b/app/Database/seeds/settings.yml @@ -333,6 +333,13 @@ options: '' type: int description: 'The length of a pilot''s ID' +- key: pilots.id_code + name: 'Pilot ID Code' + group: pilots + value: '' + options: '' + type: text + description: 'Fixed ICAO code for pilot IDs' - key: pilots.auto_accept name: 'Auto Accept New Pilot' group: pilots diff --git a/app/Models/User.php b/app/Models/User.php index 8e1def5c..741774dd 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -131,8 +131,9 @@ class User extends Authenticatable public function getIdentAttribute(): string { $length = setting('pilots.id_length'); + $ident_code = filled(setting('pilots.id_code')) ? setting('pilots.id_code') : optional($this->airline)->icao; - return optional($this->airline)->icao.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT); + return $ident_code.str_pad($this->pilot_id, $length, '0', STR_PAD_LEFT); } /**