Fix pirep->ident usage issues (#1347)

* Update table.blade.php

* Update show.blade.php

* Update pirep_card.blade.php

* Update latest_pireps.blade.php

* Update ProfileController.php

Removed non used airports, added necessary relationships for eager loading.

Also removed `fields` 'cause it is already being loaded when `fields.field` is used. No need to query it twice.

* Update ProfileController.php
This commit is contained in:
B.Fatih KOZ 2021-11-09 00:08:19 +03:00 committed by GitHub
parent 358f0b663e
commit 2dbe19fdcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 14 deletions

View File

@ -80,7 +80,7 @@ class ProfileController extends Controller
public function show($id)
{
/** @var \App\Models\User $user */
$user = User::with(['awards', 'fields', 'fields.field'])
$user = User::with('airline', 'awards', 'current_airport', 'fields.field', 'home_airport', 'last_pirep', 'rank')
->where('id', $id)
->first();
@ -89,13 +89,11 @@ class ProfileController extends Controller
return redirect(route('frontend.dashboard.index'));
}
$airports = $this->airportRepo->all();
$userFields = $this->userRepo->getUserFields($user, true);
return view('profile.index', [
'user' => $user,
'userFields' => $userFields,
'airports' => $airports,
'acars' => $this->acarsEnabled(),
]);
}

View File

@ -2,8 +2,7 @@
<div class="row">
<div class="col-sm-10">
<p>
<a href="{{ route('frontend.pireps.show', [$pirep->id]) }}">
{{ $pirep->airline->code }}{{ $pirep->ident }}</a>
<a href="{{ route('frontend.pireps.show', [$pirep->id]) }}">{{ $pirep->ident }}</a>
-
{{ $pirep->dpt_airport->name }}
(<a href="{{route('frontend.airports.show', [

View File

@ -4,8 +4,7 @@
@section('content')
<div class="row">
<div class="col-sm-8">
<h2>{{ $pirep->airline->icao }}{{ $pirep->ident }}
: {{ $pirep->dpt_airport_id }} to {{ $pirep->arr_airport_id }}</h2>
<h2>{{ $pirep->ident }} : {{ $pirep->dpt_airport_id }} to {{ $pirep->arr_airport_id }}</h2>
</div>
<div class="col-sm-4">

View File

@ -17,8 +17,7 @@
@foreach($pireps as $pirep)
<tr>
<td>
<a href="{{ route('frontend.pireps.show', [
$pirep->id]) }}">{{ $pirep->airline->code }}{{ $pirep->ident }}</a>
<a href="{{ route('frontend.pireps.show', [$pirep->id]) }}">{{ $pirep->ident }}</a>
</td>
<td>
@if($pirep->dpt_airport){{ $pirep->dpt_airport->name }}@endif

View File

@ -2,15 +2,15 @@
@foreach($pireps as $p)
<tr>
<td style="padding-right: 10px;">
<span class="title">{{ $p->airline->code }} {{ $p->flight_number }}</span>
<span class="title">{{ $p->ident }}</span>
</td>
<td>
<a href="{{route('frontend.airports.show', [$p->dpt_airport_id])}}">{{$p->dpt_airport_id}}</a>
&nbsp;-&nbsp;
<a href="{{route('frontend.airports.show', [$p->arr_airport_id])}}">{{$p->arr_airport_id}}</a>&nbsp;
@if(!empty($p->aircraft))
{{ optional($p->aircraft)->registration }} ({{ $p->aircraft->icao }})
@endif
<a href="{{route('frontend.airports.show', [$p->arr_airport_id])}}">{{$p->arr_airport_id}}</a>
</td>
<td>
{{ optional($p->aircraft)->ident }}
</td>
</tr>
@endforeach