/** * 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); }
/** * Bootstrap any application services. * * @return void */ public function boot() { Validator::extend('booking_overlap', function ($attribute, $value, $parameters) { $input = \Input::all(); if (empty($input['from']) || empty($input['to'])) { return true; } $from = Carbon::createFromFormat('d-m-Y', $input['from']); $to = Carbon::createFromFormat('d-m-Y', $input['to']); $booking = new Booking(); $overlapping = $booking->overlappingAccepted($from, $to); return !$overlapping; }); }
/** * 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 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'); } } }
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')]); }
/** * 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(); }
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]); }
/** * 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]); }
/** * 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; }
/** * 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)); } }
/** * 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); }
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; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { try { $booking = Booking::findOrFail($id); } catch (ModelNotFoundException $e) { return redirect('booking')->withErrors("Booking with id " . $id . " not found"); } return view('booking.edit')->with(['booking' => $booking]); }
public function index() { $apartments = Apartment::all(); $bookings = Booking::all(); foreach ($bookings as $booking) { $booking->apartmentName = Apartment::find($booking->apartment_id)->name; } return view('admin.index', compact('apartments', 'bookings')); }
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 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]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $items = Item::all(); $bookings = Booking::all(); $pickups = Pickup::all(); $ids = Pickup::lists('booking_id'); $delayed = DB::table('bookings')->whereNotIn('id', $ids)->get(); //bookings which are not in pickups $date = date('Y-m-d'); return view('stockmaster.index', ['user' => Auth::user(), 'items' => $items, 'delayed' => $delayed, 'bookings' => $bookings, 'pickups' => $pickups, 'date' => $date]); }
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; }
/** * Email Booking Confirmation * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function booking_confirmation(Request $request) { $booking_data = session('booking_data'); $data = $this->prepare_email_data($booking_data); $emails = $data['emails']; Mail::send('emails.confirmation', ['data' => $data], function ($message) use($emails) { $message->to($emails)->subject('Test - Booking Confirmed'); }); session()->flash('flash_message', 'Your booking was successful'); session()->flash('flash_time', Booking::find($booking_data->id)->created_at); return redirect('bookings/my-bookings'); }
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'); }
private function returnToUserBooking($userID) { $bokings = \App\Booking::all(); $userBookings; foreach ($bokings as $b) { if ($b::userID == $booking::userID) { $userBookings::add($b); } } return view('customerLogin', ['bookings' => $userBookings]); // TODO Corect view }
public function index() { $start = Carbon::today()->startOfDay(); $end = Carbon::today()->endOfDay(); $bookings = Booking::whereBetween('updated_at', [$start, $end])->where('status', 'paid')->lists('travel_company_id'); $todayBookingsCompanies = array_unique($bookings->toArray()); // $com_list = Payment::whereBetween('updated_at', [$start, $end]) // ->lists('travel_company_id') // ->toArray(); // $c_lists = array_unique($com_list); $today_companies = TravelCompany::whereIn('id', $todayBookingsCompanies)->get(); // dd($todayBookingsCompanies, $bookings, $today_companies); return view('admin.accounting.index', ['companies' => $today_companies])->with('bookings', $bookings); }
/** * 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]); }
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]); }
/** * 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'); } }
/** * Check that losers score is not higher than the winners score. */ public function moreValidation($validator) { $match = Result::where('match_id', '=', $this->input('match_id'))->first(); $booking = Booking::find($this->input('match_id')); $validator->after(function ($validator) use($match, $booking) { if ($this->input('win')) { if ($this->input('user_score') < $this->input('opponent_score')) { $validator->errors()->add('user_score', ' Your score must be higher than your opponent'); } } elseif (!$this->input('result_by_default')) { if ($this->input('user_score') > $this->input('opponent_score')) { $validator->errors()->add('user_score', ' Your score must be lower than your opponent'); } } if ($match->created_at != $match->created_at) { $validator->errors()->add('match_id', 'Match score already entered by opponent'); } if ($booking->booking_date > date('Y-m-d')) { $validator->errors()->add('match_id', 'Match has not been played yet'); } }); }
/** * 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(); } } } }