#14 associate/disassociate aircraft from flights
This commit is contained in:
@@ -181,7 +181,6 @@ class FlightController extends BaseController
|
|||||||
public function aircraft(Request $request)
|
public function aircraft(Request $request)
|
||||||
{
|
{
|
||||||
$id = $request->id;
|
$id = $request->id;
|
||||||
print_r($request->toArray());
|
|
||||||
|
|
||||||
$flight = $this->flightRepository->findWithoutFail($id);
|
$flight = $this->flightRepository->findWithoutFail($id);
|
||||||
if (empty($flight)) {
|
if (empty($flight)) {
|
||||||
@@ -189,16 +188,14 @@ class FlightController extends BaseController
|
|||||||
return redirect(route('admin.flights.index'));
|
return redirect(route('admin.flights.index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// add aircraft to flight
|
||||||
* update specific aircraftdata
|
|
||||||
*/
|
|
||||||
if ($request->isMethod('post')) {
|
if ($request->isMethod('post')) {
|
||||||
// add
|
$flight->aircraft()->syncWithoutDetaching([$request->aircraft_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dissassociate fare from teh aircraft
|
// remove aircraft from flight
|
||||||
elseif ($request->isMethod('delete')) {
|
elseif ($request->isMethod('delete')) {
|
||||||
// del
|
$flight->aircraft()->detach($request->aircraft_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->return_aircraft_view($flight);
|
return $this->return_aircraft_view($flight);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<td>{!! $ac->registration !!}</td>
|
<td>{!! $ac->registration !!}</td>
|
||||||
<td style="width: 10%; text-align: center;" class="form-inline">
|
<td style="width: 10%; text-align: center;" class="form-inline">
|
||||||
{!! Form::open(['url' => '/admin/flights/'.$flight->id.'/aircraft', 'method' => 'delete', 'class' => 'flight_ac_frm']) !!}
|
{!! Form::open(['url' => '/admin/flights/'.$flight->id.'/aircraft', 'method' => 'delete', 'class' => 'flight_ac_frm']) !!}
|
||||||
{!! Form::hidden('flight_id', $flight->id) !!}
|
{!! Form::hidden('aircraft_id', $flight->id) !!}
|
||||||
<div class='btn-group'>
|
<div class='btn-group'>
|
||||||
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>',
|
{!! Form::button('<i class="glyphicon glyphicon-trash"></i>',
|
||||||
['type' => 'submit',
|
['type' => 'submit',
|
||||||
|
|||||||
Reference in New Issue
Block a user