Use optional() around the airport fields (#537)

* Use optional() around the airport fields

* Add null-coalesce around full_name
This commit is contained in:
Nabeel S 2020-02-03 12:23:58 -05:00 committed by GitHub
parent 5e4a003a92
commit 94cfbd4748
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 39 deletions

View File

@ -291,17 +291,17 @@ class GeoService extends Service
$route = new GeoJson(); $route = new GeoJson();
//# Departure Airport //# Departure Airport
$route->addPoint($flight->dpt_airport->lat, $flight->dpt_airport->lon, [ $route->addPoint(optional($flight->dpt_airport)->lat, optional($flight->dpt_airport)->lon, [
'name' => $flight->dpt_airport->icao, 'name' => $flight->dpt_airport_id,
'popup' => $flight->dpt_airport->full_name, 'popup' => optional($flight->dpt_airport)->full_name ?? $flight->dpt_airport_id,
'icon' => 'airport', 'icon' => 'airport',
]); ]);
if ($flight->route) { if ($flight->route) {
$all_route_points = $this->getCoordsFromRoute( $all_route_points = $this->getCoordsFromRoute(
$flight->dpt_airport->icao, $flight->dpt_airport_id,
$flight->arr_airport->icao, $flight->arr_airport_id,
[$flight->dpt_airport->lat, $flight->dpt_airport->lon], [optional($flight->dpt_airport)->lat, optional($flight->dpt_airport)->lon],
$flight->route $flight->route
); );
@ -315,9 +315,9 @@ class GeoService extends Service
} }
} }
$route->addPoint($flight->arr_airport->lat, $flight->arr_airport->lon, [ $route->addPoint(optional($flight->arr_airport)->lat, optional($flight->arr_airport)->lon, [
'name' => $flight->arr_airport->icao, 'name' => $flight->arr_airport_id,
'popup' => $flight->arr_airport->full_name, 'popup' => optional($flight->arr_airport)->full_name ?? $flight->arr_airport_id,
'icon' => 'airport', 'icon' => 'airport',
]); ]);
@ -342,9 +342,9 @@ class GeoService extends Service
/* /*
* PLANNED ROUTE * PLANNED ROUTE
*/ */
$planned->addPoint($pirep->dpt_airport->lat, $pirep->dpt_airport->lon, [ $planned->addPoint(optional($pirep->dpt_airport)->lat, optional($pirep->dpt_airport)->lon, [
'name' => $pirep->dpt_airport->icao, 'name' => $pirep->dpt_airport_id,
'popup' => $pirep->dpt_airport->full_name, 'popup' => optional($pirep->dpt_airport)->full_name ?? $pirep->dpt_airport_id,
]); ]);
$planned_route = $this->acarsRepo->forPirep($pirep->id, AcarsType::ROUTE); $planned_route = $this->acarsRepo->forPirep($pirep->id, AcarsType::ROUTE);
@ -355,9 +355,9 @@ class GeoService extends Service
]); ]);
} }
$planned->addPoint($pirep->arr_airport->lat, $pirep->arr_airport->lon, [ $planned->addPoint(optional($pirep->arr_airport)->lat, optional($pirep->arr_airport)->lon, [
'name' => $pirep->arr_airport->icao, 'name' => $pirep->arr_airport_id,
'popup' => $pirep->arr_airport->full_name, 'popup' => optional($pirep->arr_airport)->full_name ?? $pirep->arr_airport_id,
'icon' => 'airport', 'icon' => 'airport',
]); ]);

View File

@ -5,7 +5,7 @@
<h3 class="box-title">{{ Form::label('dpt_airport_id', 'Dep ICAO') }}</h3> <h3 class="box-title">{{ Form::label('dpt_airport_id', 'Dep ICAO') }}</h3>
</div> </div>
<div class="box-body"><p class="lead"> <div class="box-body"><p class="lead">
{{ $flight->dpt_airport->icao }} - {{ $flight->dpt_airport->name }} {{ $flight->dpt_airport_id }} - {{ optional($flight->dpt_airport)->name }}
</p></div> </p></div>
</div> </div>
</div> </div>
@ -17,7 +17,7 @@
<h3 class="box-title">{{ Form::label('arr_airport_id', 'Arrival ICAO') }}</h3> <h3 class="box-title">{{ Form::label('arr_airport_id', 'Arrival ICAO') }}</h3>
</div> </div>
<div class="box-body"><p class="lead"> <div class="box-body"><p class="lead">
{{ $flight->arr_airport->icao }} - {{ $flight->arr_airport->name }} {{ $flight->arr_airport_id }} - {{ optional($flight->arr_airport)->name }}
</p> </p>
</div> </div>
</div> </div>
@ -43,7 +43,7 @@
@if($flight->alt_airport_id) @if($flight->alt_airport_id)
<div class="form-group"> <div class="form-group">
{{ Form::label('alt_airport_id', 'Alt Airport Id:') }} {{ Form::label('alt_airport_id', 'Alt Airport Id:') }}
<p>{{ $flight->alt_airport->icao }}</p> <p>{{ $flight->alt_airport_id }}</p>
</div> </div>
@endif @endif

View File

@ -19,11 +19,11 @@
{{$flight->ident}} {{$flight->ident}}
</a> </a>
</td> </td>
<td>{{ $flight->dpt_airport->icao }}</td> <td>{{ $flight->dpt_airport_id }}</td>
<td> <td>
{{ $flight->arr_airport->icao }} {{ $flight->arr_airport_id }}
@if($flight->alt_airport) @if($flight->alt_airport)
(Alt: {{ $flight->alt_airport->icao }}) (Alt: {{ $flight->alt_airport_id }})
@endif @endif
</td> </td>
{{--<td>{{ $flight->route }}</td>--}} {{--<td>{{ $flight->route }}</td>--}}

View File

@ -58,9 +58,9 @@
{{ $flight->ident }} {{ $flight->ident }}
</a> </a>
</td> </td>
<td class="text-left">{{ $flight->dpt_airport->name }} <td class="text-left">{{ optional($flight->dpt_airport)->name }}
(<a href="{{route('frontend.airports.show', (<a href="{{route('frontend.airports.show',
['id'=>$flight->dpt_airport->icao])}}">{{$flight->dpt_airport->icao}}</a>) ['id' => $flight->dpt_airport_id])}}">{{$flight->dpt_airport_id}}</a>)
</td> </td>
<td>{{ $flight->dpt_time }}</td> <td>{{ $flight->dpt_time }}</td>
<td>{{ $flight->arr_time }}</td> <td>{{ $flight->arr_time }}</td>

View File

@ -15,10 +15,10 @@
<tr> <tr>
<td>@lang('common.departure')</td> <td>@lang('common.departure')</td>
<td> <td>
{{ $flight->dpt_airport->name }} {{ optional($flight->dpt_airport)->name ?? $flight->dpt_airport_id }}
(<a href="{{route('frontend.airports.show', [ (<a href="{{route('frontend.airports.show', [
'id' => $flight->dpt_airport->icao 'id' => $flight->dpt_airport_id
])}}">{{$flight->dpt_airport->icao}}</a>) ])}}">{{$flight->dpt_airport_id}}</a>)
@ {{ $flight->dpt_time }} @ {{ $flight->dpt_time }}
</td> </td>
</tr> </tr>
@ -26,20 +26,20 @@
<tr> <tr>
<td>@lang('common.arrival')</td> <td>@lang('common.arrival')</td>
<td> <td>
{{ $flight->arr_airport->name }} {{ optional($flight->arr_airport)->name ?? $flight->arr_airport_id }}
(<a href="{{route('frontend.airports.show', [ (<a href="{{route('frontend.airports.show', [
'id' => $flight->arr_airport->icao 'id' => $flight->arr_airport_id
])}}">{{$flight->arr_airport->icao}}</a>) ])}}">{{$flight->arr_airport_id }}</a>)
@ {{ $flight->arr_time }}</td> @ {{ $flight->arr_time }}</td>
</tr> </tr>
@if($flight->alt_airport_id) @if($flight->alt_airport_id)
<tr> <tr>
<td>@lang('flights.alternateairport')</td> <td>@lang('flights.alternateairport')</td>
<td> <td>
{{ $flight->alt_airport->name }} {{ optional($flight->alt_airport)->name ?? $flight->alt_airport_id }}
(<a href="{{route('frontend.airports.show', [ (<a href="{{route('frontend.airports.show', [
'id' => $flight->alt_airport->icao 'id' => $flight->alt_airport_id
])}}">{{$flight->alt_airport->icao}}</a>) ])}}">{{$flight->alt_airport_id}}</a>)
</td> </td>
</tr> </tr>
@endif @endif

View File

@ -17,7 +17,7 @@
"x-saved-class" is the class to add/remove if the bid exists or not "x-saved-class" is the class to add/remove if the bid exists or not
If you change it, remember to change it in the in-array line as well If you change it, remember to change it in the in-array line as well
--}} --}}
@if (!setting('pilots.only_flights_from_current') || $flight->dpt_airport->icao == Auth::user()->current_airport->icao) @if (!setting('pilots.only_flights_from_current') || $flight->dpt_airport_id == Auth::user()->current_airport->icao)
<button class="btn btn-round btn-icon btn-icon-mini save_flight <button class="btn btn-round btn-icon btn-icon-mini save_flight
{{ in_array($flight->id, $saved, true) ? 'btn-info':'' }}" {{ in_array($flight->id, $saved, true) ? 'btn-info':'' }}"
x-id="{{ $flight->id }}" x-id="{{ $flight->id }}"
@ -33,17 +33,17 @@
<div class="col-sm-7"> <div class="col-sm-7">
{{--<table class="table-condensed"></table>--}} {{--<table class="table-condensed"></table>--}}
<span class="title">{{ strtoupper(__('flights.dep')) }}&nbsp;</span> <span class="title">{{ strtoupper(__('flights.dep')) }}&nbsp;</span>
{{ $flight->dpt_airport->name }} {{ optional($flight->dpt_airport)->name ?? $flight->dpt_airport_id }}
(<a href="{{route('frontend.airports.show', [ (<a href="{{route('frontend.airports.show', [
'id' => $flight->dpt_airport->icao 'id' => $flight->dpt_airport_id
])}}">{{$flight->dpt_airport->icao}}</a>) ])}}">{{$flight->dpt_airport_id}}</a>)
@if($flight->dpt_time), {{ $flight->dpt_time }}@endif @if($flight->dpt_time), {{ $flight->dpt_time }}@endif
<br/> <br/>
<span class="title">{{ strtoupper(__('flights.arr')) }}&nbsp;</span> <span class="title">{{ strtoupper(__('flights.arr')) }}&nbsp;</span>
{{ $flight->arr_airport->name }} {{ optional($flight->arr_airport)->name ?? $flight->arr_airport_id }}
(<a href="{{route('frontend.airports.show', [ (<a href="{{route('frontend.airports.show', [
'id' => $flight->arr_airport->icao 'id' => $flight->arr_airport_id
])}}">{{$flight->arr_airport->icao}}</a>) ])}}">{{$flight->arr_airport_id}}</a>)
@if($flight->arr_time), {{ $flight->arr_time }}@endif @if($flight->arr_time), {{ $flight->arr_time }}@endif
<br/> <br/>
@if($flight->distance) @if($flight->distance)