public function store(BookingRequest $request) { $booking = array('car_type_id' => $request->car_type_id, 'number_of_passengers' => $request->number_of_passengers, 'pickup_time' => $request->pickup_date_part . ' ' . $request->pickup_time_part, 'ip_info' => $request->ip_info); $newBooking = Booking::create($booking); flash()->success('Your booking has been created!')->important(); if (!empty($request->comment1)) { //children comment $comment1 = array('booking_id' => $newBooking->id, 'comment_type_id' => '1', 'role_id' => '1', 'comment' => $request->comment1); Comment::create($comment1); } if (!empty($request->comment2)) { //general comment $comment2 = array('booking_id' => $newBooking->id, 'comment_type_id' => '2', 'role_id' => '1', 'comment' => $request->comment2); Comment::create($comment2); } $change = array('booking_id' => $newBooking->id, 'change_type_id' => '4', 'user_id' => Auth::user()->id, 'from' => null, 'to' => null); Change::create($change); $passenger = User::firstOrNew(['email' => $request->email]); $passenger->name = $request->name; $passenger->phone = $request->phone; $passenger->save(); $role = array('booking_id' => $newBooking->id, 'role_type_id' => '2', 'user_id' => $passenger->id); Role::create($role); $price = array('booking_id' => $newBooking->id, 'income_type_id' => '1', 'amount_eur' => $request->price); Income::create($price); $locationArray = $request->location; foreach ($request->address as $order => $address_id) { $route_point = null; $route_point = array('booking_id' => $newBooking->id, 'location_id' => $locationArray[$order], 'address_id' => $address_id, 'order' => $order); Route_point::create($route_point); } return redirect('bookings'); }
/** * 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]); }
public function run() { DB::table('bookings')->delete(); Booking::create(['booking_date' => '2015-11-11', 'booking_text' => 'sample text', 'credere_id' => 1, 'debere_id' => 2, 'amount' => 10]); Booking::create(['booking_date' => '2015-12-11', 'booking_text' => 'sample text', 'credere_id' => 2, 'debere_id' => 3, 'amount' => 11]); Booking::create(['booking_date' => '2015-10-11', 'booking_text' => 'sample text', 'credere_id' => 2, 'debere_id' => 1, 'amount' => 15.5]); }
public function save(Request $request) { if (!$request->session()->has('quotation')) { return redirect('/monthly')->withErrors("ไม่พบข้อมูลการจองพื้นที่"); } $rules = array('type' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return redirect('/monthly')->withErrors($validator); } $user = \Auth::user(); if ($user->role != 2) { return redirect('/monthly')->withErrors("user permission denied."); } $quotation = $request->session()->get('quotation'); $rows = $quotation["rows"]; $products = $quotation["products"]; $arr_product = explode('|', $products); $name = $quotation["productName"]; $booking_code = date('YmdHms') . '-' . $user->id; foreach ($rows as $key => $row) { $booking = Booking::create(['sale_at' => $row->opened_at, 'userID' => $user->id, 'userCode' => $user->code, 'quantity' => count($arr_product), 'totalPrice' => $row->price, 'code' => $booking_code, 'productName' => $name, 'status' => 'BK', 'type' => $request->input('type'), 'payment_type' => 2]); $this->saveDetail($booking, $arr_product, $user); } $request->session()->forget('quotation'); return view('monthly.success', ['rows' => $quotation['rows'], 'products' => $quotation['products'], 'productName' => $quotation['productName'], 'thai_date' => $quotation['thai_date'], 'total_price' => $quotation['total_price'], 'booking_code' => $booking_code, 'type' => $request->input('type')]); }
/** * Run the database seeds. * * @return void */ public function run() { $json = File::get(storage_path() . '/jsondata/bookings.json'); $data = json_decode($json); foreach ($data as $obj) { Booking::create(array('id' => $obj->id, 'customer_id' => $obj->customer_id, 'user_id' => $obj->user_id, 'car_id' => $obj->car_id, 'diemdon' => $obj->diemdon, 'diemden' => $obj->diemden, 'yeucau' => $obj->yeucau, 'bookingDate' => $obj->bookingDate, 'returnDate' => $obj->returnDate)); } }
public function booking(Request $request) { $values = $request->all(); $booking = Booking::create($values); $user = Auth::user(); $items = Item::all(); $i = 0; return view('customer', ['i' => $i, 'booking' => $booking, 'user' => $user, 'items' => $items]); }
public function storeBooking(Requests\CreateBookingRequest $request) { $input = $request->all(); $from = Carbon::createFromFormat('d-m-Y', $input['from']); $to = Carbon::createFromFormat('d-m-Y', $input['to']); $input['phone'] = $input['country_code'] . $input['phone']; unset($input['country_code']); $input['from'] = $from; $input['to'] = $to; Booking::create($input); return redirect('inn/booking/thankyou'); }
function booking(Request $request) { $items = Item::all(); $i = 0; $values = $request->all(); $rules = ['name' => 'required|max:100', 'adrsl1' => 'required', 'adrsl2' => 'required', 'place' => 'required', 'pin' => 'required|digits:6', 'email' => 'required|email', 'phone' => 'required|digits:10', 'pickdate' => 'required|date_format:Y-m-d|after:today']; $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return view('main', ['i' => $i, 'items' => $items, 'req_errors' => $validator->errors(), 'req_inputs' => $request->all()]); // ['status'=>'fail','error'=>'invalid data',,]; } $booking = Booking::create($values); return view('main', ['i' => $i, 'booking' => $booking, 'items' => $items]); }
public function bookingRoomPost(Request $request) { $data['title'] = "Make reservation"; //save to guest table $guest = new Guest(); $guest = $request->all(); $guest_id = Guest::create($guest); //save to booking table $booking = new Booking(); $booking = $request->all(); $booking['guest_id'] = $guest_id->id; Booking::create($booking); //update status room Room::where('name', $booking['room_name'])->update(array('status' => 'N')); return redirect()->route('listbooking_com'); }
/** * Store a newly created booking. If the booking is for a ladder match * store a record for each player in the results table, to enter their results once * they have completed their match. Refer to Ladder controller. * * @return Response */ public function store_booking(StoreBookingRequest $request) { $booking = Booking::create($request->all()); if ($booking->booking_cat_id == 3) { $player1 = new Result(); $player1->match_id = $booking->id; $player1->player_id = $booking->player1_id; $player1->save(); $player2 = new Result(); $player2->match_id = $booking->id; $player2->player_id = $booking->player2_id; $player2->save(); } $booking_data = Booking::find($booking->id); session()->flash('booking_data', $booking_data); //with array of emails dates and booking info - go to a get request - create session with cancellation data. return redirect('email/booking-confirmation'); //session()->flash('flash_message', 'Your booking was successful'); //return redirect('bookings/my-bookings'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $date = new DateTime(); $date->setTimezone(new DateTimeZone('Asia/Bangkok')); $rules = array('products' => 'required', 'date' => 'required', 'productName' => 'required', 'totalPrice' => 'required|integer', 'number' => 'required|integer'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('result' => false, 'message' => 'invalid input field.')); } $user = \Auth::user(); if ($user == null) { return response()->json(array('result' => false, 'message' => 'user is not define.')); } $booking_code = date('YmdHms') . '-' . $user->id; $booking = Booking::create(['sale_at' => $request->input('date'), 'userID' => $user->id, 'userCode' => $user->code, 'quantity' => $request->input('number'), 'totalPrice' => $request->input('totalPrice'), 'code' => $booking_code, 'productName' => $request->input('productName'), 'status' => 'BK', 'type' => $request->input('type'), 'payment_type' => 1]); if ($booking == null) { return response()->json(array('result' => false, 'message' => 'booking create fails.')); } //$open = (object) $arr[$i]; $products_arr = $request->input('products'); $count = 0; $detail_result = []; foreach ($products_arr as $key => $product_arr) { # code... $product = (object) $product_arr; $calendar = Calendar::where('opened_at', $request->input('date'))->where('code', $product->code)->get()->first(); $detail = BookingDetail::create(['code' => $date->format('Ymd-His') . '-' . $user->id . '-' . ($count + 1), 'bookingID' => $booking->id, 'bookingCode' => $booking->code, 'zoneID' => $calendar->zoneID, 'zoneCode' => $calendar->code, 'zoneNumber' => $product->name, 'price' => $product->price, 'status' => 'BK', 'sale_at' => $request->input('date')]); if ($detail != null) { array_push($detail_result, $detail->id); $count++; } } //end foreach if ($count == count($products_arr)) { return response()->json(array('result' => true, 'message' => 'success', 'bookingCode' => $booking->code, 'detail' => $detail_result)); } return response()->json(array('result' => false, 'message' => 'booking create fails.')); }
function booking(Request $request) { $values = $request->all(); Booking::create($values); return view('main', ['values' => $values]); }
public function customer(CheckCustomerRequest $request) { $info = $request->all(); $booking = $this->mc_decrypt($info['key_encrypt'], $this->vif_key); $data_out = ['code_booking' => $info['phone'], 'pax_customer' => $info['pax_customer'], 'first_name' => $info['first_name'], 'last_name' => $info['last_name'], 'nation' => $info['nation'], 'phone' => $info['phone'], 'email' => $info['email'], 'request' => $info['request'], 'method_payment' => $info['method_payment'], 'time_in' => $this->convert_datetime($booking['date_in'], $booking['time_in']), 'time_out' => $this->convert_datetime($booking['date_out'], $booking['time_out']), 'adult' => $booking['adult'], 'child' => $booking['child'], 'baby' => $booking['baby'], 'airport' => $booking['airport'], 'single' => $booking['single'], 'twin' => $booking['twin'], 'mn_single' => $booking['mn_single'], 'mn_twin' => $booking['mn_twin'], 'mn_child' => $booking['mn_child'], 'total' => $booking['total'], 'status' => 0]; $book = Booking::create($data_out); if ($data_out['method_payment'] == 'BT') { return view('booking.bt', compact('data_out')); } elseif ($data_out['method_payment'] == 'PP') { return view('booking.pp', compact('data_out')); } else { return view('booking.cc', compact('data_out')); } //return $this->mc_decrypt($info['key_encrypt'], $this->vif_key); }
/** * make booking for the user */ public function makeBooking(Request $request) { //dd($request->get('booking')); if (Auth::user()->type != 4) { # code... return redirect()->back(); } $val = $this->customValidation($request->get('booking')); if ($val == 0) { # code... return redirect()->back()->withErrors("You haven't made a booking."); } elseif ($val > 1) { return redirect()->back()->withErrors("You can only book one appointment at a time."); } foreach ($request->get('booking') as $_temp) { # code... if ($_temp != "none") { # code... $appointId = $_temp; } } //dd($appointId); $appointment = Appointment::findOrFail($appointId); if ($appointment->available == 1) { # code... $booking = Booking::create(['appointment_id' => $appointment->id, 'user_id' => Auth::user()->id]); $appointment->update(['available' => 0]); return redirect('home/patient'); } return redirect()->back()->withErrors("Error creating the booking"); }
public function customer(Request $request) { $info = $request->all(); $booking = $this->mc_decrypt($info['key_encrypt'], $this->vif_key); $time_book = $this->decode_time($info['key_user']); $booking_old = Booking::where('time_book', $time_book)->get(); $service_out = []; $key = 0; $service_bf = 0; $service_af = 0; $services = DB::table('service_lang')->join('services', 'service_lang.service_id', '=', 'services.id')->where('service_lang.lang_id', current_lang_id())->select('service_lang.*', 'services.*')->get(); foreach ($services as $service) { if ($service->choice == 0) { $service_out[$key]['name'] = $service->name; if ($service->option == 0) { $ser_bf = $booking['total_room'] * $service->value / 100; $service_bf += $ser_bf; $service_out[$key]['money'] = $ser_bf; } else { $service_bf += $service->value; $service_out[$key]['money'] = $service->value; } $key++; } } foreach ($services as $service) { if ($service->choice == 1) { $service_out[$key]['name'] = $service->name; if ($service->option == 0) { $ser_af = ($booking['total_room'] + $service_bf) * $service->value / 100; $service_af += $ser_af; $service_out[$key]['money'] = $ser_af; } else { $service_af += $service->value; $service_out[$key]['money'] = $service->value; } $key++; } } //$service_out = array_reverse($service_out); $data_out = ['pax_customer' => $info['pax_customer'], 'first_name' => $info['first_name'], 'last_name' => $info['last_name'], 'nation' => $info['nation'], 'phone' => $info['phone'], 'emails' => $info['email'], 'request' => $info['request'], 'method_payment' => $info['method_payment'], 'time_in' => $this->convert_datetime($booking['date_in'], $booking['time_in']), 'time_out' => $this->convert_datetime($booking['date_out'], $booking['time_out']), 'adult' => $booking['adult'], 'child' => $booking['child'], 'baby' => $booking['baby'], 'airport' => $booking['airport'], 'single' => $booking['single'], 'twin' => $booking['twin'], 'mn_single' => $booking['mn_single'], 'mn_twin' => $booking['mn_twin'], 'mn_child' => $booking['mn_child'], 'total' => $booking['total'], 'total_hours' => $booking['total_hours'], 'total_room' => $booking['total_room'], 'price' => $booking['price'], 'status' => 0, 'time_book' => $time_book, 'plane' => $info['plane'], 'reason' => $info['reason'], 'source' => $info['source'], 'guest_name' => $info['guest_name'], 'guest_com' => $info['guest_com'], 'guest_email' => $info['guest_email'], 'guest_phone' => $info['guest_phone'], 'lang_id' => current_lang_id()]; if (count($booking_old) == 0) { list($day, $month, $year) = explode('/', $booking['date_in']); $month = str_pad($month, 2, "0", STR_PAD_LEFT); $day = str_pad($day, 2, "0", STR_PAD_LEFT); $year = $year - 2010; $id_max = DB::table('bookings')->max('id'); $id_max++; $id_max = str_pad($id_max, 4, "0", STR_PAD_LEFT); $data_out['code_booking'] = $year . $month . $day . $id_max; $booking_code = $data_out['code_booking']; $book = Booking::create($data_out); $arr_datein[] = array(); $str = $booking['date_in']; $arr_datein = explode('/', $str); $day_in = $arr_datein[0]; $mo_in = $arr_datein[1]; $y_in = $arr_datein[2]; $arr_timein = explode(':', $booking['time_in']); $h_in = $arr_timein[0]; if ($h_in >= 12) { $date = $day_in . "/" . $mo_in . "/" . $y_in; } else { $date = $this->convert_datetime($str, $booking['time_in']); $date = $date - 24 * 60 * 60; $date = date("d/m/Y", $date); } if ($booking['airport'] == 1) { if ($booking['single'] > 0) { $policy = DB::table('policy')->where('date', $date)->where('roomtype_id', 1)->first(); $room = $policy->room - $booking['single']; DB::table('policy')->where('date', $date)->where('roomtype_id', 1)->update(['room' => $room]); } if ($booking['twin'] > 0) { $policy = DB::table('policy')->where('date', $date)->where('roomtype_id', 2)->first(); $room = $policy->room - $booking['single']; DB::table('policy')->where('date', $date)->where('roomtype_id', 2)->update(['room' => $room]); } } else { if ($booking['twin'] > 0) { $policy = DB::table('policy')->where('date', $date)->where('roomtype_id', 3)->first(); $room = $policy->room - $booking['twin']; DB::table('policy')->where('date', $date)->where('roomtype_id', 3)->update(['room' => $room]); } } } else { $data_out['code_booking'] = $booking_old[0]['code_booking']; $data_out['code_booking'] = str_pad($data_out['code_booking'], 9, "0", STR_PAD_LEFT); $booking_code = $data_out['code_booking']; DB::table('bookings')->where('id', $booking_old[0]['id'])->update($data_out); } $key_encrypt = $this->mc_encrypt($data_out, $this->vif_key); if ($data_out['method_payment'] == 'BT') { $lang = \Session::get('locale'); if (current_lang_id() == 1) { Mail::send('emails.bank', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['emails'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Yêu cầu đặt phòng.'); }); Mail::send('emails.bank', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to('*****@*****.**', 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Yêu cầu đặt phòng.'); }); if (!is_null($data_out['guest_email']) && $data_out['guest_email'] != '') { Mail::send('emails.bank', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['guest_email'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SleepPod Yêu cầu đặt phòng.'); }); } return view('layouts.booking.bt', compact('data_out', 'service_out')); } else { Mail::send('emails.bank-en', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['emails'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SLEEPPOD BOOKING INFORMATION.'); }); Mail::send('emails.bank-en', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to('*****@*****.**', 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SLEEPPOD BOOKING INFORMATION.'); }); if (!is_null($data_out['guest_email']) && $data_out['guest_email'] != '') { Mail::send('emails.bank-en', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['guest_email'], 'VATC SleepPod')->from('*****@*****.**')->subject('VATC SLEEPPOD BOOKING INFORMATION.'); }); } return view('layouts.booking.bt-en', compact('data_out', 'service_out')); } } elseif ($data_out['method_payment'] == 'PP') { $total_usd = (int) $booking['total'] / 22000; $total_usd = round($total_usd, 2); $total_usd = number_format($total_usd, 2); $token = $this->get_access_token($this->clientId, $this->clientSecret, $this->url, $this->postToken); $payment = '{ "transactions": [{ "amount":{ "total":"' . $total_usd . '", "currency":"USD" }, "description":"Total ' . $total_usd . ' USD." }], "payer": { "payment_method":"paypal" }, "intent":"sale", "redirect_urls": { "cancel_url":"http://hanoiairporthotels.vn/paypal/cancel", "return_url":"http://hanoiairporthotels.vn/paypal/success" } }'; //$json = json_encode($payment); $url_2 = "https://api.paypal.com/v1/payments/payment"; $json_resp = $this->make_post_call($token, $url_2, $payment); foreach ($json_resp['links'] as $link) { if ($link['rel'] == 'approval_url') { $payment_detail_url = $link['href']; $payment_detail_method = $link['method']; } } $pay_id = $json_resp['id']; DB::table('bookings')->where('code_booking', $booking_code)->update(['pay_id' => $pay_id]); $this->Redirect_to($payment_detail_url, false); //return view('layouts.booking.pp', compact('data_out','service_out')); } else { $lang = \Session::get('locale'); if (current_lang_id() == 1) { return view('layouts.booking.cc', compact('data_out', 'key_encrypt', 'service_out')); } else { return view('layouts.booking.cc-en', compact('data_out', 'key_encrypt', 'service_out')); } } //return $this->mc_decrypt($info['key_encrypt'], $this->vif_key); }
public function add($inputData) { return Booking::create($inputData); }
public function store(ReservationRequest $request) { //booking $booking = array('car_type_id' => $request->car_type_id, 'number_of_passengers' => $request->number_of_passengers, 'pickup_time' => $request->pickup_date_part . ' ' . $request->pickup_time_part); $newBooking = Booking::create($booking); // main passenger //user (main passenger) $mainpassenger = new User(); $mainpassenger->name = $request->name; $mainpassenger->phone = $request->phone; $mainpassenger->save(); //role (main passenger) $role = array('booking_id' => $newBooking->id, 'role_type_id' => '2', 'user_id' => $mainpassenger->id); Role::create($role); //email receiver //user (email receiver) $emailreceiver = User::firstOrCreate(['email' => $request->email]); //role (email receiver) $role = array('booking_id' => $newBooking->id, 'role_type_id' => '5', 'user_id' => $emailreceiver->id); Role::create($role); //route points //start $route_point = array('booking_id' => $newBooking->id, 'location_id' => $request->start_location_id, 'sub_location_id' => $request->start_sub_location_id, 'description' => $request->start_description, 'order' => 1); Route_point::create($route_point); //via points $descriptionArray = $request->description; //if via array is not empty if (!empty($request->location_id)) { foreach ($request->location_id as $order => $location_id) { $route_point = null; $route_point = array('booking_id' => $newBooking->id, 'location_id' => $location_id, 'description' => $descriptionArray[$order], 'order' => $order); Route_point::create($route_point); } } //end $route_point = null; $route_point = array('booking_id' => $newBooking->id, 'location_id' => $request->end_location_id, 'description' => $request->end_description, 'order' => 99); Route_point::create($route_point); //general comment if (!empty($request->comment)) { $comment = array('booking_id' => $newBooking->id, 'comment_type_id' => '2', 'role_id' => '1', 'comment' => $request->comment); Comment::create($comment); } //price $price = Income_list::where('car_type_id', $request->car_type_id)->where('direction_id', $request->direction_id)->where('income_type_id', 1)->whereNull('user_id')->first(); $income = array('booking_id' => $newBooking->id, 'income_type_id' => '1', 'amount_eur' => $price->amount_eur); Income::create($income); //cashflow if ($request->payment_type_id == 3) { $receiver_id = 1; //receiver is driver $due_date = $newBooking->pickup_time; //on the day of travel } else { $receiver_id = 4; //receiver is us (admin) $pickup_time = new Carbon($newBooking->pickup_time); $due_date = $pickup_time->subHours(48); //48 hours before trip } $cashflow = array('booking_id' => $newBooking->id, 'payer_id' => 2, 'receiver_id' => $receiver_id, 'payment_type_id' => $request->payment_type_id, 'payment_status_id' => 1, 'amount_eur' => $price->amount_eur, 'due_date' => $due_date); Cashflow::create($cashflow); //log reservation creation $change = array('booking_id' => $newBooking->id, 'change_type_id' => '4', 'user_id' => 1, 'from' => null, 'to' => null); Change::create($change); //send email Mail::queue('emails.reservation', ['passenger' => $mainpassenger], function ($message) use($emailreceiver) { $message->from('*****@*****.**', 'Transfer Praha')->to($emailreceiver->email, null)->subject('Booking confirmation'); }); flash()->success('Your booking has been created!')->important(); return redirect('reservation/confirmation'); }
public function store($data) { return Booking::create($data); }