public function approve(Request $request) { $bookingHistory = BookingHistory::findOrFail($request->input('id')); $bookingHistory->status = 1; $bookingHistory->save(); $data = ['name' => $bookingHistory->name, 'phone' => $bookingHistory->phone, 'email' => $bookingHistory->email, 'pickupDate' => $bookingHistory->getPickupTimeString(), 'returnDate' => $bookingHistory->getReturnTimeString(), 'price' => $bookingHistory->price]; // Mail::send('emails.approval', $data, function ($message) { // $message->subject('Your Vespa Booking Has Been Approved'); // $message->from(env('SENDER_EMAIl'), 'Vespa'); // $message->to('*****@*****.**'); // }); return redirect()->route('bookingHistory.index'); }
public function store(Request $request, DateService $dateService, PricingService $pricingService) { // $vesp = json_decode($request->input('vespa'),true); // dd($request->input()); $pickupDate = $dateService->getCarbonDateFromDateString($request->input('pickupDate'), 'Y-m-d H:i:s'); // dd($pickupDate); $returnDate = $dateService->getCarbonDateFromDateString($request->input('returnDate'), 'Y-m-d H:i:s'); // Calculate Price $price = $pricingService->getPriceCalculation($pickupDate, $returnDate, $request->input('quantity')); $vespas = json_decode($request->input('vespa'), true); $vespasName = []; foreach ($vespas as $vespa) { $v = Vespa::find($vespa['code']); $initStock = $v->stock; $stock = $initStock - $vespa['amount']; $v->stock = $stock; $v->save(); // dd($vespa['code']); array_push($vespasName, $v->name); } BookingHistory::create(['name' => $request->input('name'), 'phone' => $request->input('phone'), 'email' => $request->input('email'), 'comment' => $request->input('comment'), 'vespa' => $request->input('vespa'), 'pickup_time' => $request->input('pickupDate'), 'return_time' => $request->input('returnDate'), 'quantity' => $request->input('quantity'), 'price' => $price]); return redirect()->route('book.thankyou'); }