diff --git a/app/Http/Resources/Flight.php b/app/Http/Resources/Flight.php index 11743795c..2a4030c1b 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 + // Check if there is a callsign too + if (!empty($this->callsign) && !setting('simbrief.callsign', true)) { + $res['ident'] = $this->atc.' | '.$this->ident; + } else { + $res['ident'] = $this->ident; + } if (empty($res['load_factor'])) { $res['load_factor'] = setting('flights.default_load_factor'); 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 * 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 * 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)