public function addbooking() { $booking = new Booking(); $booking->restaurant_name = Input::get('place_name'); $booking->username = \Auth::user()->name; $booking->time = Input::get('time'); $booking->date = Input::get('date'); $booking->location = Input::get('location'); $booking->save(); return redirect('bookings'); }
public function createPassenger(Request $request, $id) { //$input = Requests::all(); $this->validate($request, ['trip_id' => 'required', 'name' => 'required|min:3', 'countPasanger' => 'required']); $passenger = new Booking(); $passenger->trip_id = $id; $passenger->name = $request->name; $passenger->countPasanger = $request->countPassenger; $passenger->save(); return redirect('admin/editTrip/' . $id); }
/** * Store the booking * * @return response */ public function storeBooking(Request $request, $category_id) { $category = Category::find($category_id); if (!$category) { dd('category does not exist'); } $booking = new Booking(); $booking->appointment_name = $request->get('appointment_name'); $booking->appointment_description = $request->get('appointment_description'); $booking->time_booked = Carbon::now(); $booking->category_id = $category->id; $booking->save(); return response()->json($booking); }
public function add($id) { $input = Request::all(); $peminjam = Peminjam::select('id')->where('nim/nip', $input['nipnim'])->first(); $rules = array('nipnim' => 'required|exists:peminjam,nim/nip', 'mulai' => 'required', 'selesai' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { //return $this->failed(array('message' => $validator->messages())); echo "Validation"; return view('error'); } else { $booking_mulai = date('Y-m-d H:i:s', strtotime($input['mulai'])); $booking_selesai = date('Y-m-d H:i:s', strtotime($input['selesai'])); $check = 0; /* Cek apakah barang sedang dipinjam oleh orang lain */ $check += Transaksi::where('id_alat', $id)->where('dikembalikan', '0000-00-00 00:00:00')->count(); /* Cek apakah barang sudah dibooking oleh orang lain */ $check += Booking::where('id_alat', $id)->where(function ($query) use($booking_mulai, $booking_selesai) { $query->where(function ($query) use($booking_mulai, $booking_selesai) { $query->where('mulai', '>=', $booking_mulai)->where('mulai', '<=', $booking_selesai)->where('selesai', '>=', $booking_selesai); })->orwhere(function ($query) use($booking_mulai, $booking_selesai) { $query->where('mulai', '<=', $booking_mulai)->where('selesai', '>', $booking_mulai)->where('mulai', '<', $booking_selesai)->where('selesai', '>=', $booking_selesai); })->orwhere(function ($query) use($booking_mulai, $booking_selesai) { $query->where('mulai', '<=', $booking_mulai)->where('selesai', '>=', $booking_mulai)->where('selesai', '<=', $booking_selesai); })->orwhere(function ($query) use($booking_mulai, $booking_selesai) { $query->where('mulai', '>=', $booking_mulai)->where('selesai', '<=', $booking_selesai); }); })->count(); /* Cek apakah barang sedang dipelihara */ $check += Pemeliharaan::where('id_alat', $id)->where('mulai', '<=', $booking_mulai)->where('selesai', '0000-00-00 00:00:00')->count(); if ($check == 0) { $booking = new Booking(); $booking->id_alat = $id; $booking->id_pengguna = $peminjam->id; $booking->mulai = $booking_mulai; $booking->selesai = $booking_selesai; $booking->save(); //return $this->success(); return redirect('/dibooking'); } else { //return $this->failed(array('message' => "Barang belum dikembalikan")); echo "Barang belum dikembalikan" . $id; return view('error'); } } }
public function createBooking(Request $request) { $userID = $request->input('userid'); $showingID = $request->input('showingid'); $seats = $request->input('seats'); $showing = Showing::find($showingID)->get()->first(); if ($showing) { if ($showing->seats >= $seats) { $showing->seats = $showing->seats - $seats; $showing->save(); $booking = new Booking(); $booking->user_id = $userID; $booking->seats = $seats; $booking->showing_id = $showingID; $booking->save(); return true; } } return false; }
public function bookSlot($slot_id) { if ($slot_id != null) { //1. Get user id //2. Get venue_slot_id //3. Dump all the details as JSON //4. Update the details for the particaular slot //Update the particular slot status to NA $slot = VenueRoomSlot::where('id', $slot_id)->first(); //Club is only allowed to do two bookings on a day //First check for booking count on that day //If count >= 2 //Do not allow to book them the room $bookingDate = $slot->date; $userId = Auth::user()->id; $venueRoomSlotIds = VenueRoomSlot::where('date', $bookingDate)->lists('id'); //Get all bookings off this user on the date //Which are not disapproved //When he is trying to book the room $bookings = Booking::where('user_id', $userId)->where('disapproved_by', null)->whereIn('venue_room_slot_id', $venueRoomSlotIds)->get(); if (count($bookings) >= 2) { //Bookings Not Allowed return "You can not book any more room on " . $bookingDate; } else { if ($slot->status == 'AV') { $slot->status = 'NA'; $slot->save(); } else { //Redirect to All Booking Page // return Redirect::to('clubbookings'); return "Could not book the room"; } $slotId = $slot_id; $postData = Input::all(); $bookingDetails['applicantName'] = $postData['applicantName']; $bookingDetails['applicantRegistrationNumber'] = $postData['applicantRegistrationNumber']; $bookingDetails['clubName'] = $postData['clubname']; $bookingDetails['contact'] = $postData['contact']; $bookingDetails['typeoffunction'] = $postData['typeoffunction']; $bookingDetails['purpose'] = $postData['purpose']; $bookingDetails['equipments'][] = $postData['equipmentcheckbox']; $bookingDetails['informationdesk'] = $postData['informationdesk']; $bookingDetails['audiovisual'] = $postData['audiovisual']; $bookingDetails['eventname'] = $postData['eventname']; $bookingDetails['posters'] = $postData['posters']; $bookingDetails['displayboard'] = $postData['displayboard']; $bookingDetails['banners'] = $postData['banners']; $booking = new Booking(); $booking->venue_room_slot_id = $slotId; $booking->user_id = $userId; $booking->details = json_encode($bookingDetails); $booking->save(); //Redirect to All Booking Page return Redirect::to('clubbookings'); // return ""; } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['bookingdate' => 'required']); $dates = explode(',', $request->input('bookingdate')); if ($request->input('breakfast')) { $breakfast = 'on'; } else { $breakfast = 'off'; } if ($request->input('lunch')) { $lunch = 'on'; } else { $lunch = 'off'; } if ($request->input('dinner')) { $dinner = 'on'; } else { $dinner = 'off'; } foreach ($dates as $date) { $booking = new Booking(); $booking->bookingdate = $date; $booking->user_id = Auth::user()->id; $booking->breakfast = $breakfast; $booking->lunch = $lunch; $booking->dinner = $dinner; $booking->save(); } Flash::success('আপননার খাবারের নির্দেশনা গ্রহণ করা হয়েছে!'); return redirect('/booking'); }
$select_statement = 'SELECT * FROM bookings WHERE ' . "'" . $data['check_in'] . "'" . ' <= bookings.end AND ' . "'" . $data['check_out'] . "'" . ' >= START AND bookings.status = ' . "'" . 'confirmed' . "'" . 'AND bookings.property_id = ' . $property_id; $overlapping_bookings = DB::select($select_statement); if (count($overlapping_bookings) > 0) { $errorArr = array(); foreach ($overlapping_bookings as $overlapping_booking) { array_push($errorArr, 'Sorry, there is already a booking from ' . date('F d, Y', strtotime($overlapping_booking->start)) . ' to ' . date('F d, Y', strtotime($overlapping_booking->end))); } return redirect(url('/property/' . $data['property_id']))->withErrors($errorArr); } $booking = new \App\Booking(); $booking->customer_id = Auth::id(); $booking->property_id = $property_id; $booking->start = $data['check_in']; $booking->end = $data['check_out']; $booking->status = 'requested'; $booking->save(); return redirect(url('/property/' . $data['property_id']))->with('successes', array('You have made a request for ' . date('F d, Y', strtotime($booking->start)) . ' to ' . date('F d, Y', strtotime($booking->end)) . '. ')); })); Route::get('/admin', array('middleware' => 'auth', function () { if (!Auth::check()) { abort(403, 'Must be logged in. '); } $currentUser = Auth::user(); if (!$currentUser->is_admin) { abort(403, 'Must be an administrator. '); } $users = User::all()->sortBy('created_at'); foreach ($users as $user) { $user->customer_num_bookings_confirmed = count(Booking::where('customer_id', $user->id)->where('status', 'confirmed')->get()); $user->customer_num_bookings_rejected = count(Booking::where('customer_id', $user->id)->where('status', 'rejected')->get()); $user->customer_num_bookings_requested = count(Booking::where('customer_id', $user->id)->where('status', 'requested')->get());
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function inquiry_storeatas() { $tour = Input::all(); $tourname = Input::get('tourname'); $tourdate = Input::get('tourdate'); $tourdateto = Input::get('tourdateto'); $news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get(); $customers = new Customers(array($cust_name = Input::get('name'), $email = Input::get('email'), $phone = Input::get('phone'), $country = Input::get('country'))); $bookings = new Booking(array($cust_name = Input::get('name'), $message = Input::get('message'))); $bookings->cust_name = $cust_name; $bookings->tour_name = $tourname; $customers->cust_name = $cust_name; $customers->email = $email; $customers->phone = $phone; $customers->country = $country; $bookings->tour_date = $tourdateto; //$bookings->price = $tourprice->price; //$bookings->status = $status; $bookings->save(); $customers->save(); return \Redirect::back()->with('message', 'Your inquiry has been successfully send to us.', $tourname); }
/** * Delete existing booking, and replace with the block booking. * @param int $court * @param date $date * @param int $timeslot * @param string $description booking description * @return boolean */ public function overRideExistingBooking($court, $date, $timeslot, $description) { Booking::where('booking_date', '=', $date)->where('court_id', '=', $court)->where('time_slot_id', '=', $timeslot)->delete(); $new_booking = new Booking(); $new_booking->time_slot_id = $timeslot; $new_booking->booking_date = $date; $new_booking->court_id = $court; $new_booking->booking_description = $description; $new_booking->booking_cat_id = 4; $new_booking->player1_id = \Auth::user()->id; $new_booking->save(); }
/** * @param $passengers * @param $request * @param $user_id * @param $trip_id * @param string $status * @param bool|string $number * * @param bool $paid * * @return \App\Booking */ private function insertIntoDatabase($passengers, $request, $user_id, $trip_id, $status = "reserved", $number = false, $paid = false) { $travel_company_id = Trip::find($trip_id)->travel_company->id; $orNum = $number; $input = []; for ($i = 1; $i <= $passengers; $i++) { $number = $orNum == false ? null : $this->number(); $credentials = array_where($request, function ($k) use($i) { return ends_with($k, "_{$i}"); }); $booking = new Booking(); $input["passenger_name_{$i}"] = $booking->passenger_name = $credentials["passenger_name_{$i}"]; $input["passenger_sex_{$i}"] = $booking->passenger_sex = $credentials["passenger_sex_{$i}"]; $input["passenger_id_type_{$i}"] = $booking->passenger_id_type = $credentials["passenger_id_type_{$i}"]; $input["passenger_id_number_{$i}"] = $booking->passenger_id_number = $credentials["passenger_id_number_{$i}"]; $input["passenger_id_exp_date_{$i}"] = $booking->passenger_id_exp_date = $credentials["passenger_id_exp_date_{$i}"]; $input["passenger_dob_{$i}"] = $booking->passenger_dob = $this->time->carbonize($credentials["passenger_dob_{$i}"]); $input["passenger_citizenship_{$i}"] = $booking->passenger_citizenship = $credentials["passenger_citizenship_{$i}"]; // $input["passenger_reporting_time_{$i}"] = $booking -> passenger_reporting_time = $credentials["passenger_reporting_time_{$i}"]; $input["passenger_user_id_{$i}"] = $booking->user_id = $user_id; $input["passenger_trip_id_{$i}"] = $booking->trip_id = $trip_id; $input["passenger_code_{$i}"] = $booking->code = $this->code(); $booking->status = $status; $input["passenger_ticket_number_{$i}"] = $booking->ticket_number = $number; $input["passenger_travel_company_id_{$i}"] = $booking->travel_company_id = $travel_company_id; $booking->save(); if ($paid == true) { $this->make_payment($booking, $travel_company_id); } } return $input; }
public function saveCalendar(Request $request) { Date::truncate(); $dates = json_decode($request->dopbcp_schedule); foreach ($dates as $date => $book) { $booking = new Date(); $booking->date = $date; $booking->price = $book->price; $booking->status = $book->status; $booking->save(); } $data = json_decode($request->data); if ($data->status == 'booked') { $booking = new Booking(); $booking->first_name = "ADMIN"; $booking->message = $data->message; $booking->check_in = $data->start; $booking->check_out = $data->end; $booking->save(); } return json_encode(array('success' => true)); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return Response */ public function store(Request $request) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(2); $rules = array('jenis_barang' => 'required', 'id_pembooking' => 'required|integer', 'waktu_booking_mulai' => 'required', 'waktu_booking_selesai' => 'required'); $validator = Validator::make(Input::all(), $rules); /* process the login */ if ($validator->fails()) { return $validator->messages()->toJson(); } else { if (!checkDateTime(Input::get('waktu_booking_mulai'))) { return "Waktu booking mulai tidak valid"; } if (!checkDateTime(Input::get('waktu_booking_selesai'))) { return "Waktu booking selesai tidak valid"; } if (strtotime(Input::get('waktu_booking_mulai')) >= strtotime(Input::get('waktu_booking_selesai'))) { return "Waktu booking mulai > waktu booking selesai"; } $now = Carbon::now()->addHours(7)->toDateTimeString(); $curTime = strtotime($now); if ($curTime >= strtotime(Input::get('waktu_booking_mulai'))) { return "Waktu booking mulai > waktu sekarang"; } /* cek id pembooking */ $pengguna = Pengguna::find(Input::get('id_pembooking')); if (!$pengguna) { return "ID pengguna tidak ditemukan"; } $alat_sesuai_jenis = Peralatan::where('jenis', '=', Input::get('jenis_barang'))->get(); $selected_id = -1; $input_booking_mulai_time = strtotime(Input::get('waktu_booking_mulai')); $input_booking_selesai_time = strtotime(Input::get('waktu_booking_selesai')); foreach ($alat_sesuai_jenis as $alat) { $available = true; /* Cek di tabel booking */ $booking_of_alat = Booking::where('id_barang', '=', $alat->id)->get(); foreach ($booking_of_alat as $booking) { $booking_mulai_time = strtotime($booking->waktu_booking_mulai); $booking_selesai_time = strtotime($booking->waktu_booking_selesai); if ($input_booking_mulai_time > $booking_mulai_time && $input_booking_mulai_time < $booking_selesai_time || $input_booking_selesai_time > $booking_mulai_time && $input_booking_selesai_time < $booking_selesai_time || $booking_mulai_time > $input_booking_mulai_time && $booking_mulai_time < $input_booking_selesai_time || $booking_selesai_time > $input_booking_mulai_time && $booking_selesai_time < $input_booking_selesai_time) { $available = false; } } /* Cek di tabel transaksi */ if ($available) { $transaksi_of_alat = Transaksi::where('id_barang', '=', $alat->id)->get(); foreach ($transaksi_of_alat as $transaksi) { $transaksi_pinjam_time = $transaksi->waktu_pinjam; $transaksi_rencana_kembali_time = $transaksi->waktu_rencana_kembali; if ($input_booking_mulai_time > $transaksi_pinjam_time && $input_booking_mulai_time < $transaksi_rencana_kembali_time || $input_booking_selesai_time > $transaksi_pinjam_time && $input_booking_selesai_time < $transaksi_rencana_kembali_time || $transaksi_pinjam_time > $input_booking_mulai_time && $transaksi_pinjam_time < $input_booking_selesai_time || $transaksi_rencana_kembali_time > $input_booking_mulai_time && $transaksi_rencana_kembali_time < $input_booking_selesai_time) { $available = false; } } } if ($available) { $selected_id = $alat->id; } } if ($selected_id < 1) { return "Tidak ada alat tersedia"; } else { /* cek tanggal */ if (strtotime(Input::get('waktu_booking_selesai')) <= strtotime(Input::get('waktu_booking_mulai'))) { return "Tanggal tidak valid"; } else { /* store */ $booking = new Booking(); $booking->id_barang = $selected_id; $booking->id_pembooking = Input::get('id_pembooking'); $booking->waktu_booking_mulai = Input::get('waktu_booking_mulai'); $booking->waktu_booking_selesai = Input::get('waktu_booking_selesai'); $booking->save(); return $booking->id; } } } }