From e38b8a5c0d6739419a3ee92f597a9e86df18caa5 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Tue, 5 Sep 2023 22:35:44 +0300 Subject: [PATCH 1/6] Update Flight Resource --- app/Http/Resources/Flight.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 11743795c..46ea5d553 100644 --- a/app/Http/Resources/Flight.php +++ b/app/Http/Resources/Flight.php @@ -43,7 +43,13 @@ public function toArray($request) { $res = parent::toArray($request); - $res['ident'] = $this->ident; + // Display flight callsign if pilot ident usage is not forced by VA + if (!setting('simbrief.callsign', true)) { + $callsign = !empty($this->callsign) ? $this->airline->icao.$this->callsign : $this->airline->icao.$this->flight_number; + $res['ident'] = $callsign.' | '.$this->ident; + } else { + $res['ident'] = $this->ident; + } if (empty($res['load_factor'])) { $res['load_factor'] = setting('flights.default_load_factor'); From 936cc03555455ec0bc68c71c55cdb4d5bda1d83f Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Wed, 6 Sep 2023 00:14:28 +0300 Subject: [PATCH 2/6] Add atc as model attribute --- app/Http/Resources/Flight.php | 3 +-- app/Models/Flight.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 46ea5d553..82923e7f9 100644 --- a/app/Http/Resources/Flight.php +++ b/app/Http/Resources/Flight.php @@ -45,8 +45,7 @@ public function toArray($request) // Display flight callsign if pilot ident usage is not forced by VA if (!setting('simbrief.callsign', true)) { - $callsign = !empty($this->callsign) ? $this->airline->icao.$this->callsign : $this->airline->icao.$this->flight_number; - $res['ident'] = $callsign.' | '.$this->ident; + $res['ident'] = $this->atc.' | '.$this->ident; } else { $res['ident'] = $this->ident; } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 4c605c16a..60e34bb46 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -21,6 +21,7 @@ /** * @property string id * @property mixed ident + * @property mixed atc * @property Airline airline * @property int airline_id * @property mixed flight_number @@ -198,6 +199,26 @@ public function ident(): Attribute ); } + /** + * Get the flight atc callsign, JBU1900 or JBU8FK + */ + public function atc(): Attribute + { + return Attribute::make( + get: function ($_, $attrs) { + $flight_atc = optional($this->airline)->icao; + + if (!empty($this->callsign)) { + $flight_atc .= $this->callsign; + } else { + $flight_atc .= $this->flight_number; + } + + return $flight_atc; + } + ); + } + /** * @param $day * From 121ccca69acbfbe1846a5085ee0d5c233faa021e Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Thu, 7 Sep 2023 22:09:27 +0300 Subject: [PATCH 3/6] Update callsign displays Callsign was already there in the blade, used model driven callsign display and added simbrief callsign settings to match flight resource results. --- resources/views/layouts/default/flights/show.blade.php | 7 +++++-- resources/views/layouts/default/flights/table.blade.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/views/layouts/default/flights/show.blade.php b/resources/views/layouts/default/flights/show.blade.php index 8f14af3cb..a93080b5a 100644 --- a/resources/views/layouts/default/flights/show.blade.php +++ b/resources/views/layouts/default/flights/show.blade.php @@ -8,6 +8,9 @@

{{ $flight->ident }} + @if(filled($flight->callsign) && !setting('simbrief.callsign', true)) + {{ '| '. $flight->atc }} + @endif @if ($acars_plugin && $bid) Load in vmsACARS @elseif ($acars_plugin) @@ -56,10 +59,10 @@ {{ $flight->route }} @endif - @if(filled($flight->callsign)) + @if(filled($flight->callsign) && !setting('simbrief.callsign', true)) @lang('flights.callsign') - {{ $flight->airline->icao }} {{ $flight->callsign }} + {{ $flight->atc }} @endif @if(filled($flight->notes)) diff --git a/resources/views/layouts/default/flights/table.blade.php b/resources/views/layouts/default/flights/table.blade.php index 6e3a02111..8dc5a3494 100644 --- a/resources/views/layouts/default/flights/table.blade.php +++ b/resources/views/layouts/default/flights/table.blade.php @@ -26,6 +26,9 @@ style="max-width: 80px; width: 100%; height: auto;"/> @endif {{ $flight->ident }} + @if(filled($flight->callsign) && !setting('simbrief.callsign', true)) + {{ '| '. $flight->atc }} + @endif

@@ -63,9 +66,9 @@ ({{$flight->arr_airport_id}}) @if($flight->arr_time), {{ $flight->arr_time }}@endif
- @if(filled($flight->callsign)) + @if(filled($flight->callsign) && !setting('simbrief.callsign', true)) {{ strtoupper(__('flights.callsign')) }}  - {{ $flight->airline->icao }} {{ $flight->callsign }} + {{ $flight->atc }}
@endif @if($flight->distance) From b0853f53c1077cda29c4484d47492d044608e88a Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Thu, 7 Sep 2023 22:16:33 +0300 Subject: [PATCH 4/6] Update resource To use same settings as blades --- app/Http/Resources/Flight.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 82923e7f9..8ce013b04 100644 --- a/app/Http/Resources/Flight.php +++ b/app/Http/Resources/Flight.php @@ -44,7 +44,7 @@ public function toArray($request) $res = parent::toArray($request); // Display flight callsign if pilot ident usage is not forced by VA - if (!setting('simbrief.callsign', true)) { + if (!empty($this->callsign) && !setting('simbrief.callsign', true)) { $res['ident'] = $this->atc.' | '.$this->ident; } else { $res['ident'] = $this->ident; From 5414086afd8067b224a285d7b01a3f43251ee2af Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Thu, 7 Sep 2023 22:22:37 +0300 Subject: [PATCH 5/6] Update Flight.php --- app/Http/Resources/Flight.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 8ce013b04..2a4030c1b 100644 --- a/app/Http/Resources/Flight.php +++ b/app/Http/Resources/Flight.php @@ -44,6 +44,7 @@ public function toArray($request) $res = parent::toArray($request); // Display flight callsign if pilot ident usage is not forced by VA + // Check if there is a callsign too if (!empty($this->callsign) && !setting('simbrief.callsign', true)) { $res['ident'] = $this->atc.' | '.$this->ident; } else { From 0832da38914c53da4df3233901536af4cbdbcff0 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Sun, 10 Sep 2023 11:34:57 +0300 Subject: [PATCH 6/6] Add atc attribute to user model Same as flight model, if a user has an alphanumeric callsign, VA's should be able to use it easily too when needed. If no callsign is defined, ident is used. (padding with zero's are not used in atc attribute 'cause this can be just FDX1 or DLH72 without a leading zero as atc callsign) --- app/Models/User.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index b74dfbb27..058b986e2 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -30,6 +30,7 @@ * @property string api_key * @property mixed timezone * @property string ident + * @property string atc * @property string curr_airport_id * @property string home_airport_id * @property string avatar @@ -186,6 +187,23 @@ public function ident(): Attribute ); } + /** + * Format the pilot atc callsign, either return alphanumeric callsign or ident + * + * @return Attribute + */ + public function atc(): Attribute + { + return Attribute::make( + get: function ($_, $attrs) { + $ident_code = filled(setting('pilots.id_code')) ? setting('pilots.id_code') : optional($this->airline)->icao; + $atc = filled($attrs['callsign']) ? $ident_code.$attrs['callsign'] : $ident_code.$attrs['pilot_id']; + + return $atc; + } + ); + } + /** * Return a "privatized" version of someones name - First and middle names full, last name initials *