/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $input = $request->all(); // Format phone number. Ex: (+84) 909787874 $input['phone'] = '(' . $input['phoneCode'] . ')' . $input['phone']; // Format date for database insert $input['arrival_date'] = date('Y-m-d', strtotime($input['arrival_date'])); $input['departure_date'] = date('Y-m-d', strtotime($input['departure_date'])); // Format hotel room refernce for saving $single = $input['single']; $double = $input['double']; $twin = $input['twin']; $triple = $input['triple']; $input['hotel_room_reference'] = json_encode(compact('single', 'double', 'twin', 'triple')); $booking = TourBooking::create($input); // Send email to customer Mail::send('email.booking', $input, function ($message) use($input) { $message->from('*****@*****.**', 'Akjra Vu'); $message->to($input['email'])->subject(Config::get('myconfig.SITE_NAME') . ' - Booking!'); }); Session::flash('request_message', 'Your request has been sent successfully. Thank you!'); $booking = TourBooking::findOrFail($booking->id); // hard code alias for testing return view('booking.step3', ['booking' => $booking, 'tour' => Tour::find($input['tour_id'])]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $destination = TourBooking::findOrFail($id); $destination->delete(); }