/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request, $id) { $customer = $this->customer->getById($id); $flight = $this->flight->addBookingDetail($request, $id); \Session::flash('flash_message', 'New flight has been created'); return redirect()->action('CustomerController@show', [$customer]); }
/** * Creating a flight from user input. * Create a new booking and push $customer->id * and flight->id in. * * @param $request [request user input] * @param $id [getting customer id] */ public function addBookingDetail($request, $id) { $givenInput = $request->all(); $data = $this->model->create($givenInput); $customer = $this->customer->getById($id); return Booking::create(['customer_id' => $customer->id, 'flight_id' => $data->id]); }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { $this->customer->deleteById($id); \Session::flash('flash_message', 'De klant is verwijderd uit de database!'); return redirect('customer'); }