Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/Http/Resources/Flight.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
21 changes: 21 additions & 0 deletions app/Models/Flight.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* @property string id
* @property mixed ident
* @property mixed atc
* @property Airline airline
* @property int airline_id
* @property mixed flight_number
Expand Down Expand Up @@ -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
*
Expand Down
18 changes: 18 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*
Expand Down
7 changes: 5 additions & 2 deletions resources/views/layouts/default/flights/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<div class="col-12">
<h2>
{{ $flight->ident }}
@if(filled($flight->callsign) && !setting('simbrief.callsign', true))
{{ '| '. $flight->atc }}
@endif
@if ($acars_plugin && $bid)
<a href="vmsacars:bid/{{$bid->id}}" class="btn btn-info btn-sm float-right">Load in vmsACARS</a>
@elseif ($acars_plugin)
Expand Down Expand Up @@ -56,10 +59,10 @@
<td>{{ $flight->route }}</td>
</tr>
@endif
@if(filled($flight->callsign))
@if(filled($flight->callsign) && !setting('simbrief.callsign', true))
<tr>
<td>@lang('flights.callsign')</td>
<td>{{ $flight->airline->icao }} {{ $flight->callsign }}</td>
<td>{{ $flight->atc }}</td>
</tr>
@endif
@if(filled($flight->notes))
Expand Down
7 changes: 5 additions & 2 deletions resources/views/layouts/default/flights/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
</a>
</h5>
</div>
Expand Down Expand Up @@ -63,9 +66,9 @@
(<a href="{{route('frontend.airports.show', ['id' => $flight->arr_airport_id])}}">{{$flight->arr_airport_id}}</a>)
@if($flight->arr_time), {{ $flight->arr_time }}@endif
<br/>
@if(filled($flight->callsign))
@if(filled($flight->callsign) && !setting('simbrief.callsign', true))
<span class="title">{{ strtoupper(__('flights.callsign')) }}&nbsp;</span>
{{ $flight->airline->icao }} {{ $flight->callsign }}
{{ $flight->atc }}
<br/>
@endif
@if($flight->distance)
Expand Down