cleanup for aircraft fares
This commit is contained in:
parent
c732476f6d
commit
65e58c91c5
@ -16,10 +16,11 @@ class AircraftController extends BaseController
|
|||||||
/** @var AircraftRepository */
|
/** @var AircraftRepository */
|
||||||
private $aircraftRepository, $fareRepository;
|
private $aircraftRepository, $fareRepository;
|
||||||
|
|
||||||
protected function getAvailFares($all_fares, $attached_fares)
|
protected function getAvailFares($aircraft)
|
||||||
{
|
{
|
||||||
$retval = [];
|
$retval = [];
|
||||||
$avail_fares = $all_fares->except($attached_fares->modelKeys());
|
$all_fares = $this->fareRepository->all();
|
||||||
|
$avail_fares = $all_fares->except($aircraft->fares->modelKeys());
|
||||||
foreach ($avail_fares as $fare) {
|
foreach ($avail_fares as $fare) {
|
||||||
$retval[$fare->id] = $fare->name.
|
$retval[$fare->id] = $fare->name.
|
||||||
' (price: '.$fare->price.
|
' (price: '.$fare->price.
|
||||||
@ -81,13 +82,10 @@ class AircraftController extends BaseController
|
|||||||
return redirect(route('admin.aircraft.index'));
|
return redirect(route('admin.aircraft.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$attached_fares = $aircraft->fares;
|
$avail_fares = $this->getAvailFares($aircraft);
|
||||||
$all_fares = $this->fareRepository->all();
|
|
||||||
$avail_fares = $this->getAvailFares($all_fares, $attached_fares);
|
|
||||||
|
|
||||||
return view('admin.aircraft.show')
|
return view('admin.aircraft.show')
|
||||||
->with('aircraft', $aircraft)
|
->with('aircraft', $aircraft)
|
||||||
->with('attached_fares', $attached_fares)
|
|
||||||
->with('avail_fares', $avail_fares);
|
->with('avail_fares', $avail_fares);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,13 +145,10 @@ class AircraftController extends BaseController
|
|||||||
protected function return_fares_view($aircraft)
|
protected function return_fares_view($aircraft)
|
||||||
{
|
{
|
||||||
$aircraft->refresh();
|
$aircraft->refresh();
|
||||||
$attached_fares = $aircraft->fares;
|
$avail_fares = $this->getAvailFares($aircraft);
|
||||||
$all_fares = $this->fareRepository->all();
|
|
||||||
$avail_fares = $this->getAvailFares($all_fares, $attached_fares);
|
|
||||||
|
|
||||||
return view('admin.aircraft.fares')
|
return view('admin.aircraft.fares')
|
||||||
->with('aircraft', $aircraft)
|
->with('aircraft', $aircraft)
|
||||||
->with('attached_fares', $attached_fares)
|
|
||||||
->with('avail_fares', $avail_fares);
|
->with('avail_fares', $avail_fares);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($attached_fares as $atf)
|
@foreach($aircraft->fares as $atf)
|
||||||
<tr role="row" class="@if ($loop->iteration%2) even @else odd @endif">
|
<tr role="row" class="@if ($loop->iteration%2) even @else odd @endif">
|
||||||
<td class="sorting_1">{!! $atf->name !!}</td>
|
<td class="sorting_1">{!! $atf->name !!}</td>
|
||||||
<td>{!! $atf->code !!}</td>
|
<td>{!! $atf->code !!}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user