/** * This function is to store the reservation details to db. * After storing the details this function redirects to the My Reservation view. * * @return \Illuminate\Http\RedirectResponse */ public function hallReservation() { try { //set the timezone date_default_timezone_set("Asia/Colombo"); $customer_email = Auth::user()->email; $customer_id = Customer::where('email', $customer_email)->value('cus_id'); $customer_name = Customer::where('email', $customer_email)->value('name'); $hall_name = HALL::where('hall_id', session('hall_selected'))->value('title'); $event_date = session('event_date'); //create instance of the HALL_RESERVATION model $hall_reservation = new HALL_RESERVATION(); $hall_reservation->reserve_date = session('event_date'); $hall_reservation->time_slot = session('timeSlot'); $hall_reservation->total_amount = session('total_payable'); $hall_reservation->cus_id = $customer_id; $hall_reservation->hall_id = session('hall_selected'); $hall_reservation->status = 'PENDING'; $hall_reservation->save(); //retrieve the reservation id of the last saved reservation $res_id = $hall_reservation->hall_reservation_id; //delete the reservation details since already stored in the db Session::forget(['event_date', 'total_payable', 'hall_selected', 'CanPay']); //create an array in order to send the mail view with reservation details $data = array('res_id' => $res_id, 'hall_name' => $hall_name, 'event_date' => $event_date, 'name' => $customer_name); $job = new SendEmail($data, $customer_email, "initial_reservation_mail"); $this->dispatch($job); //send a initial mail /* Mail::send('emails.InitialRoomReservationMail', $data, function ($message)use($customer_email) { $message->from(env('MAIL_FROM'), env('MAIL_NAME')); $message->to($customer_email)->subject('Welcome to Amalya Reach!'); });*/ //pusher $newNotification = new Notifications(); $newNotification->notification = "New Reservation"; $newNotification->body = "Room Reservation has been made"; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'Reservation', ['message' => 'New Hall Reservation has been made']); return redirect('myreserv')->with(['hreserv_status' => 'Reservation has been successfully made']); } catch (\Exception $e) { abort(500, $e->getMessage()); } }