/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->call(function () { $trip_ids = Trip::where('departure_date', Carbon::today())->lists('id')->toArray(); Booking::where('status', 'reserved')->whereIn('trip_id', $trip_ids)->delete(); })->everyMinute(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $dt = Carbon::now(); $year = $dt->year; $month = $dt->month; $currentmonthbreakfast = Booking::where('user_id', $request->user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('breakfast', '=', 'on')->count(); $currentmonthlunch = Booking::where('user_id', $request->user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('lunch', '=', 'on')->count(); $currentmonthdinner = Booking::where('user_id', $request->user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('dinner', '=', 'on')->count(); $totalbooking = $currentmonthbreakfast + $currentmonthlunch + $currentmonthdinner; $bookings = Booking::where('user_id', $request->user()->id)->orderBy('bookingdate', 'desc')->paginate(13); $eventsbreakfast = Booking::where('user_id', $request->user()->id)->where('breakfast', 'on')->get(); $eventslunch = Booking::where('user_id', $request->user()->id)->where('lunch', 'on')->get(); $eventsdinner = Booking::where('user_id', $request->user()->id)->where('dinner', 'on')->get(); $events = array(); foreach ($eventsbreakfast as $booking) { $start = date('Y') . '-' . date('m-d', strtotime($booking->bookingdate)); $title = 'Breakfast: ' . $booking->breakfast; $color = '#468847'; $events[] = array('title' => $title, 'start' => $start, 'color' => $color); } foreach ($eventslunch as $booking) { $start = date('Y') . '-' . date('m-d', strtotime($booking->bookingdate)); $title = 'Lunch: ' . $booking->lunch; $color = '#b94a48'; $events[] = array('title' => $title, 'start' => $start, 'color' => $color); } foreach ($eventsdinner as $booking) { $start = date('Y') . '-' . date('m-d', strtotime($booking->bookingdate)); $title = 'Dinner: ' . $booking->dinner; $color = '#3a87ad'; $events[] = array('title' => $title, 'start' => $start, 'color' => $color); } return view('booking.index', ['bookings' => $bookings, 'currentmonthbreakfast' => $currentmonthbreakfast, 'currentmonthlunch' => $currentmonthlunch, 'currentmonthdinner' => $currentmonthdinner, 'totalbooking' => $totalbooking, 'events' => $events]); }
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'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return view('error'); } else { $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, kalo dibooking orang tersebut, boleh */ $check += Booking::where('id_alat', $id)->where('id_pengguna', '<>', $peminjam->id)->where('mulai', '<=', date('Y-m-d H:i:s', time()))->where('selesai', '>=', date('Y-m-d H:i:s', time()))->count(); /* Cek apakah barang sedang dipelihara */ $check += Pemeliharaan::where('id_alat', $id)->where('mulai', '<=', date('Y-m-d H:i:s', time()))->where('selesai', '0000-00-00 00:00:00')->count(); if ($check == 0) { $transaksi = new Transaksi(); $transaksi->id_alat = $id; $transaksi->id_pengguna = $peminjam->id; $transaksi->dipinjam = date('Y-m-d H:i:s', time()); $transaksi->save(); return redirect('/dipinjam'); } else { return view('error'); } } }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { $today = Carbon::today(); $tomorrow = Carbon::tomorrow(); $tomorrowbookinguser = Booking::where('bookingdate', '=', $tomorrow)->get(); $dt = Carbon::now(); $year = $dt->year; $month = $dt->month; $currentmonthbreakfast = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('breakfast', '=', 'on')->count(); $currentmonthlunch = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('lunch', '=', 'on')->count(); $currentmonthdinner = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('dinner', '=', 'on')->count(); $totalbooking = $currentmonthbreakfast + $currentmonthlunch + $currentmonthdinner; $price = Account::whereMonth('accountdate', '=', date('m'))->where('user_id', Auth::user()->id)->sum('amount'); $todaydayshop = Shop::where('shopdate', $today)->get(); $tomorrowshop = Shop::where('shopdate', $tomorrow)->get(); $bookings = Booking::where('bookingdate', '=', $today)->get(); $breakfast = Booking::where('bookingdate', '=', $today)->where('breakfast', '=', 'on')->count(); $lunch = Booking::where('bookingdate', '=', $today)->where('lunch', '=', 'on')->count(); $dinner = Booking::where('bookingdate', '=', $today)->where('dinner', '=', 'on')->count(); $t_breakfast = Booking::where('bookingdate', '=', $tomorrow)->where('breakfast', '=', 'on')->count(); $t_lunch = Booking::where('bookingdate', '=', $tomorrow)->where('lunch', '=', 'on')->count(); $t_dinner = Booking::where('bookingdate', '=', $tomorrow)->where('dinner', '=', 'on')->count(); $useraccounts = DB::table('useraccounts')->where('user_id', Auth::user()->id)->select('user_id', DB::raw("SUM(foodamount) AS t_foodamount"), DB::raw("SUM(houserent) AS t_houserent"), DB::raw("SUM(internetbill) AS t_internetbill"), DB::raw("SUM(utlitybill) AS t_utlitybill"), DB::raw("SUM(buabill) AS t_buabill"), DB::raw("SUM(pay) AS t_pay"))->get(); foreach ($useraccounts as $account) { $amount = $account->t_foodamount + $account->t_houserent + $account->t_internetbill + $account->t_utlitybill + $account->t_buabill; $balance = $amount - $account->t_pay; } return view('home', ['bookings' => $bookings, 'breakfast' => $breakfast, 'lunch' => $lunch, 'dinner' => $dinner, 't_breakfast' => $t_breakfast, 't_lunch' => $t_lunch, 't_dinner' => $t_dinner, 'tomorrow' => $tomorrow, 'todaydayshop' => $todaydayshop, 'tomorrowshop' => $tomorrowshop, 'tomorrowbookinguser' => $tomorrowbookinguser, 'balance' => $balance, 'currentmonthbreakfast' => $currentmonthbreakfast, 'currentmonthlunch' => $currentmonthlunch, 'currentmonthdinner' => $currentmonthdinner, 'totalbooking' => $totalbooking, 'price' => $price]); }
private function getBookingClub() { $oneMonthBeforeNow = Carbon::now('Asia/Kolkata')->subMonth(1); $userId = Auth::user()->id; // $allBookings = Booking::where('updated_at', '<=' , $twentyFourHourBeforeNow) $allBookings = Booking::where('user_id', $userId)->where('created_at', '>', $oneMonthBeforeNow)->orderBy('created_at', 'DESC')->with('associatedVenueRoomSlot')->with('associatedVenueRoom')->get(); return $allBookings; }
/** * A cron that will delete all reservations 24hours to the trip departure date */ public function clean() { $start = Carbon::today()->startOfDay(); $end = Carbon::today()->endOfDay(); $trip_ids = Trip::whereBetween('departure_date', [$start, $end])->lists('id')->toArray(); $cleaned = Booking::where('status', 'reserved')->whereIn('trip_id', $trip_ids)->delete(); return $cleaned; }
/** * list all checkout * @return [type] [description] */ public function checkoutPreview($room) { $data['title'] = "Checkout Preview"; $data['booking'] = $booking = Booking::where('room_name', $room)->first(); $data['guest'] = Guest::where('id', $booking['guest_id'])->first(); $data['total'] = 100; return view('receiption/checkoutPreview', $data); }
public function index() { $totalTrips = Trip::all()->count(); $totalTravelCompanies = TravelCompany::all()->count(); $totalUsers = User::all()->count(); $totalPaidBookings = Booking::where('status', 'paid')->count(); $totalBus = Rental::all()->count(); return view('admin.dashboard', ['tT' => $totalTrips, 'tU' => $totalUsers, 'tP' => $totalPaidBookings, 'tC' => $totalTravelCompanies, 'tB' => $totalBus]); }
public function delbooking() { $data = Input::get('booking_id'); $deletedRows = Booking::where('id', $data)->delete(); if ($deletedRows > 0) { return $data; } else { return -1; } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($id) { $a = Booking::where('id', $id)->update(['verify' => 1]); $b = BookingDetail::where('bookingID', $id)->update(['verify' => 1]); if ($a <= 0 || $b <= 0) { return response()->json(['result' => false, 'message' => 'can not find this booking.']); } $temp_booking = ViewBookingAndDetail::where('active', 1)->where('id', $id)->groupBy('id')->orderBy('zoneNumber')->get(); foreach ($temp_booking as $key => $value) { $value->detail = BookingDetail::where('bookingID', $value->id)->get(); $value->user = User::where('id', $value->userID)->first(); } return response()->json(['result' => true, 'message' => 'success', 'data' => $temp_booking]); }
public function search(Request $request) { $rules = array('date' => 'required', 'zoneName' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('result' => false, 'message' => 'invalid input field.')); } $user = Auth::user(); $booking_count = Booking::where('sale_at', $request->input('date'))->where('userID', $user->id)->count(); if ($booking_count > 0) { return response()->json(array('result' => false, 'message' => 'บัญชีนี้ได้ทำการจองไปแล้ว กรุณาตรวจสอบใหม่อีกครั้ง')); } $block = Calendar::where('active', 1)->where('opened_at', $request->input('date'))->where('name', $request->input('zoneName'))->groupBy('code')->get(); return response()->json(array('result' => true, 'message' => 'success.', 'data' => $block)); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update($date) { if ($date == null) { return response()->json(['result' => false, 'message' => 'date can not be null.']); } $booking = Booking::where('sale_at', $date . ' 00:00:00')->where('status', 'BK')->update(['status' => 'RM', 'active' => 0]); $booking_list = Booking::where('sale_at', $date . ' 00:00:00')->where('status', 'RM')->get(); foreach ($booking_list as $key => $book) { BookingDetail::where('bookingID', $book->id)->update(['status' => 'RM', 'active' => 0]); } if ($booking != null) { return response()->json(['result' => true, 'data' => $booking, 'message' => 'success']); } return response()->json(['result' => false, 'message' => 'clear fail.']); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Request $request) { // $rules = array('page' => 'required', 'pageSize' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('result' => false, 'message' => $validator->errors()->first())); } $page = $request->input('page'); $pageSize = $request->input('pageSize'); $skip = ($page - 1) * $pageSize; $user = \Auth::user(); $count = Booking::where('userID', $user->id)->count(); $booking = Booking::where('userID', $user->id)->orderBy('id', 'desc')->skip($skip)->take($pageSize)->get(); return response()->json(['result' => true, 'data' => $booking, 'total' => $count, 'skip' => $skip, 'take' => $pageSize]); }
public function add($id) { $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, kalo dibooking orang tersebut, boleh */ $check += Booking::where('id_alat', $id)->where('mulai', '<=', date('Y-m-d H:i:s', time()))->where('selesai', '>=', date('Y-m-d H:i:s', time()))->count(); /* Cek apakah barang sedang dipelihara */ $check += Pemeliharaan::where('id_alat', $id)->where('mulai', '<=', date('Y-m-d H:i:s', time()))->where('selesai', '0000-00-00 00:00:00')->count(); if ($check == 0) { $pemeliharaan = new Pemeliharaan(); $pemeliharaan->id_alat = $id; $pemeliharaan->mulai = date('Y-m-d H:i:s', time()); $pemeliharaan->save(); //return $this->success(); return redirect('/dipelihara'); } else { return view('error'); } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { if ($id == null) { return response()->json(array('result' => false, 'message' => 'Booking id can not be null.')); } $rules = array('id' => 'required', 'code' => 'required', 'canCheckIn' => 'required|boolean:true', 'bookingDetail' => 'required|array'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('result' => false, 'message' => 'invalid input field.')); } $date = new DateTime(); $date->setTimezone(new DateTimeZone('Asia/Bangkok')); $booking = Booking::where('id', $id)->first(); $booking->status = 'CN'; $booking->checkin_at = $date->format('Y-m-d H:i:s'); $result = $booking->save(); if (!$result) { return response()->json(array('result' => false, 'message' => 'Booking id $id check-in has error.')); } BookingDetail::where('bookingID', $id)->update(['status' => 'CN']); return response()->json(array('result' => true, 'message' => 'success.')); }
/** * Run the database seeds. * * @return void */ public function run() { $bookings = \App\Booking::where('status', 'confirmed')->get(); $fake_comments = file_get_contents("http://jsonplaceholder.typicode.com/comments"); $fake_comments = json_decode($fake_comments, true); foreach ($bookings as $booking) { if (mt_rand(0, 1)) { $comments = \App\Comment::where('booking_id', $booking->id)->get(); if (count($comments) > 0) { continue; } else { $comment = new \App\Comment(); $comment->user_id = $booking->customer_id; $comment->property_id = $booking->property_id; $comment->booking_id = $booking->id; $comment->rating = mt_rand(1, 5); $one_comment = $fake_comments[mt_rand(0, count($fake_comments) - 1)]; $comment->comment_text = $one_comment['body']; $comment->written_at = date('Y-m-d H:i:s'); $comment->save(); } } } }
/** * Eloquent Eager Loading to solve N + 1 query problem. * Get all bookings details via customer id * Receive all records in order by creation date ascending. * * @param $id [customer id] * * @return mixed [flight, passenger, outbound, cost] */ public function getBooking($id) { return $this->model->where('customer_id', $id)->orderBy('id', 'desc')->with('flight', 'passenger', 'outbound', 'cost')->get(); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $rules = array('jenis_barang' => 'required', 'id_peminjam' => 'required|integer', 'waktu_pinjam' => 'required', 'waktu_rencana_kembali' => 'required'); $validator = Validator::make(Input::all(), $rules); // process the update if ($validator->fails()) { return $validator->messages()->toJson(); } else { //cek id pengguna $pengguna = Pengguna::find(Input::get('id_peminjam')); if (!$pengguna) { return "ID pengguna tidak ditemukan"; } // update $transaksi = Transaksi::find($id); if (!$transaksi) { return "Not Found"; } if (!checkDateTime(Input::get('waktu_pinjam'))) { return "Waktu pinjam tidak valid"; } if (!checkDateTime(Input::get('waktu_rencana_kembali'))) { return "Waktu rencana kembali tidak valid"; } if (strtotime(Input::get('waktu_rencana_kembali')) <= strtotime(Input::get('waktu_pinjam'))) { return "Waktu tidak valid"; } if (Input::get('waktu_kembali') != null) { if (!checkDateTime(Input::get('waktu_kembali'))) { return "Waktu kembali tidak valid"; } if (strtotime(Input::get('waktu_kembali')) <= strtotime(Input::get('waktu_pinjam'))) { return "Waktu tidak valid"; } } $id_barang_old = $transaksi->id_barang; $barang_old = Peralatan::find($id_barang_old); $jenis_barang_old = $barang_old->jenis; $selected_id = -1; if (strcmp(Input::get('jenis_barang'), $jenis_barang_old) == 0) { $selected_id = $id_barang_old; } else { // cari peralatan baru $waktu_pinjam_time = strtotime(Input::get('waktu_pinjam')); $waktu_rencana_kembali_time = strtotime(Input::get('waktu_rencana_kembali')); foreach ($alat_sesuai_jenis as $alat) { $available = true; if (strcmp($alat->status, "Baik") != 0 || strcmp($alat->ketersediaan, "Tersedia") != 0) { $available = false; break; } //cek di data 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_selseai_time = strtotime($booking->waktu_booking_selesai); if ($waktu_pinjam_time > $booking_mulai_time && $waktu_pinjam_time < $booking_selesai_time || $waktu_rencana_kembali_time > $booking_mulai_time && $waktu_rencana_kembali_time < $booking_selesai_time || $booking_mulai_time > $waktu_pinjam_time && $booking_mulai_time < $waktu_rencana_kembali_time || $booking_selesai_time > $waktu_pinjam_time && $booking_selesai_time < $waktu_rencana_kembali_time) { $available = false; } } if ($available) { $selected_id = $alat->id; } } } $_waktu_kembali = ""; if (strcmp($transaksi->waktu_kembali, "0000-00-00 00:00:00") != 0) { $_waktu_kembali = Input::get('waktu_kembali'); } if ($selected_id < 1) { return "Tidak ada alat tersedia"; } else { $transaksi->id_barang = $selected_id; $transaksi->id_peminjam = Input::get('id_peminjam'); $transaksi->waktu_pinjam = Input::get('waktu_pinjam'); $transaksi->waktu_rencana_kembali = Input::get('waktu_rencana_kembali'); $transaksi->waktu_kembali = $_waktu_kembali; $transaksi->save(); return $transaksi->id; } } }
public function getBookingClub() { $twentyFourHourBeforeNow = Carbon::now('Asia/Kolkata')->subHour(24); $userId = Auth::user()->id; $allBookings = Booking::where('updated_at', '<=', $twentyFourHourBeforeNow)->with('associatedVenueRoomSlot')->with('associatedVenueRoom')->where('user_id', $userId)->get(); return json_encode($allBookings); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function update(Request $request) { $rules = array('bookingid' => 'required'); $validator = Validator::make($request->all(), $rules); if ($validator->fails()) { return response()->json(array('result' => false, 'message' => $validator->errors()->first())); } $booking_id = $request->input('bookingid'); $booking = Booking::where('id', $booking_id)->first(); if ($booking == null) { return response()->json(array('result' => false, 'message' => 'can not define booking from id ' . $booking_id)); } $booking->payment = 2; if ($booking->save()) { return response()->json(array('result' => true, 'message' => 'success')); } return response()->json(array('result' => false, 'message' => 'update fail')); }
public function ticketing($code) { $booking = Booking::where('code', $code)->first(); $html = view('mails.print', ['booking' => $booking])->render(); return $this->pdf->load($html)->download(); }
$user->host_num_bookings_requested += count(Booking::where('property_id', $property->id)->where('status', 'requested')->get()); $comments = Comment::where('property_id', $property->id)->get(); foreach ($comments as $comment) { $num_ratings += 1; $rating_total += $comment->rating; } } if ($num_ratings > 0) { $user->overall_rating = (double) $rating_total / (double) $num_ratings; } } $properties = Property::all()->sortBy('created_at'); foreach ($properties as $property) { $property->num_bookings_confirmed = count(Booking::where('property_id', $property->id)->where('status', 'confirmed')->get()); $property->num_bookings_rejected = count(Booking::where('property_id', $property->id)->where('status', 'rejected')->get()); $property->num_bookings_requested = count(Booking::where('property_id', $property->id)->where('status', 'requested')->get()); $property->overall_rating = floatval(DB::select('SELECT AVG(rating) AS avg FROM comments WHERE property_id = ' . $property->id . ';')[0]->avg); $property->city_name = City::find($property->city_id)->name; } return view('admin_panel', ['users' => $users, 'properties' => $properties]); })); Route::get('/property/{property_id}', function ($property_id) { /* Get the property */ $property = Property::find($property_id); /* Use property_id to find the feature/amenities row in the other table*/ $amenities = PropertyFeatures::where('property_id', $property->id)->get()[0]; /* Use the city_id to find the city name */ $property->city_name = City::find($property->city_id)->name; /* Find the owner name */ $property->owner_name = User::find($property->owner_id)->getFirstNameWithDegree(); /* Send the entire owner object to the page */
public function change_pay(Request $request) { $payment = $request->all(); if ($payment['total_pay'] > 0) { DB::table('bookings')->where('id', $payment['id'])->update(['status' => $payment['status'], 'total_pay' => $payment['total_pay']]); } else { DB::table('bookings')->where('id', $payment['id'])->update(['status' => $payment['status']]); } if ($payment['status'] == 1) { $data = Booking::where('id', $payment['id'])->get(); $data_out = $data[0]; $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 = $data_out['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 = ($data_out['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++; } } if ($payment['total_pay'] > 0) { $data_out['total_payed'] = $payment['total_pay']; } //$service_out = array_reverse($service_out); if ($data_out->lang_id == 1) { Mail::send('emails.confirm_booking', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['emails'], 'VATC SlepPod')->from('*****@*****.**')->subject('VATC SlepPod Xác nhận đặt phòng'); }); Mail::send('emails.confirm_booking', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to('*****@*****.**', 'VATC SlepPod')->from('*****@*****.**')->subject('VATC SlepPod Xác nhận đặt phòng'); }); if (!is_null($data_out['guest_email']) && $data_out['guest_email'] != '') { Mail::send('emails.confirm_booking', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['guest_email'], 'VATC SlepPod')->from('*****@*****.**')->subject('VATC SlepPod Xác nhận đặt phòng'); }); } } else { Mail::send('emails.confirm_booking-en', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['emails'], 'VATC SlepPod')->from('*****@*****.**')->subject('VATC SLEEPPOD BOOKING CONFIRMATION'); }); Mail::send('emails.confirm_booking', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to('*****@*****.**', 'VATC SlepPod')->from('*****@*****.**')->subject('VATC SlepPod Xác nhận đặt phòng'); }); if (!is_null($data_out['guest_email']) && $data_out['guest_email'] != '') { Mail::send('emails.confirm_booking-en', ['data' => $data_out, 'services' => $service_out], function ($message) use($data_out) { $message->to($data_out['guest_email'], 'VATC SlepPod')->from('*****@*****.**')->subject('VATC SLEEPPOD BOOKING CONFIRMATION'); }); } } } return Redirect::back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $pengguna = Pengguna::find($id); if (!$pengguna) { return "Not Found"; } $inBooking = Booking::where('id_pembooking', '=', $id)->count(); $inTransaksi = Transaksi::where('id_peminjam', '=', $id)->count(); if ($inBooking > 0 || $inTransaksi > 0) { return "Tidak dapat menghapus"; } else { $pengguna->delete(); return 1; } }
public function showBookingDetail($id) { $booking = Booking::where('id', $id)->with('associatedVenueRoomSlot')->with('associatedVenueRoom')->get(); // dd($booking->toArray()); return view('pages.fahistoryshow')->with('booking', $booking->toArray()); }
/** * Responds to requests to POST /bookings/edit */ public function postEdit($booking_id, Request $request) { // get the booking $booking = \App\Booking::find($booking_id); // check if booking exists if (is_null($booking)) { \Session::flash('flash_message', 'Booking not found.'); return redirect('/bookings'); } // check if the hall is booked for the given time $startTime = $request->date . 'T08:00:00.000'; $endTime = $request->date . 'T19:00:00.000'; $bookings = \App\Booking::where('booking_status_id', '=', '3')->where('id', '!=', $booking->id)->where('booking_time', '>=', $startTime)->where('booking_time', '<=', $endTime)->where('sport_hall_id', '=', $request->hall)->get(); // selected time for booking $currentBookingTime = Carbon::createFromFormat('Y-m-d H:00', $request->date . ' ' . $request->time); // hall should be booked atleast 5 hours in advance if (Carbon::now()->diffInHours($currentBookingTime, false) <= 5) { \Session::flash('flash_message', 'Booking not updated. You have to book a hall atleast 5 hours in advance. Please select an other time slot.'); return redirect('/bookings'); } // loop through all the booking on this date and check if the hall is reserved foreach ($bookings as $bookingInRange) { $startTime = Carbon::createFromFormat('Y-m-d H:00:00', $bookingInRange->booking_time); $endTime = $startTime->copy(); $endTime->addHours($bookingInRange->hours); if ($currentBookingTime->between($startTime, $endTime) && !($endTime->diffInHours($currentBookingTime) == 0)) { \Session::flash('flash_message', 'Booking not updated. Sorry the hall is already reserved for this time slot!'); return redirect('/bookings'); } } // edit the booking $booking->sport_hall_id = $request->hall; $booking->booking_time = Carbon::createFromFormat('Y-m-d H:00', $request->date . ' ' . $request->time)->toDateTimeString(); $bookingStatusId = \App\BookingStatus::where('status', '=', 'Reserved')->pluck('id'); $booking->booking_status_id = $bookingStatusId; $booking->hours = $request->hours; $booking->save(); // Done \Session::flash('flash_message', 'Your booking was modified!'); return redirect('/bookings'); }
public function addRemarkProcessRequest($id) { $booking = Booking::where('id', $id)->first(); $booking->security_remarks = Input::get('remark'); $booking->save(); return redirect('/securitynewbookings')->with('message', "Thank You ! Booking Approved"); }
/** * @param $court - string * @param $date - string * @param $timeslot - string * @return array booking data */ public function cancelledBookingData($court, $date, $timeslot) { $booking_data = Booking::where('booking_date', '=', $date)->where('court_id', '=', $court)->where('time_slot_id', '=', $timeslot)->get(); return $booking_data; }
/** * Check if there are any overlapping accepted bookings * * @param Carbon $from * @param Carbon $to * @return bool */ public function overlappingAccepted(Carbon $from, Carbon $to) { $overlapping = Booking::where('state', 'accepted')->where('to', '>=', $from)->where('from', '<=', $to)->count(); return $overlapping > 0; }
/** * Change states of all overlapping bookings * * @param Carbon $from * @param Carbon $to * @param int $room * @param int $skipId * @param string $state */ protected function batchChangeState(Carbon $from, Carbon $to, $room, $skipId, $state = 'rejected') { $rejects = Booking::where('room', $room)->where('id', '!=', $skipId)->where('to', '>=', $from)->where('from', '<=', $to)->where('to', '>', Carbon::now())->get(); foreach ($rejects as $item) { if ($item->overlappingAccepted($item->from, $item->to)) { $item->state = 'rejected'; } else { $item->state = $state; } $item->save(); } }