I have imlemented the lessons learned from your course "[Mini-Course] Laravel Breeze with User Role Areas". I am building a project for a client. How can I implement a simple room booking system without using any fancy tools such as Alpine.js, Livewire, Packages or any frontend frameworks but just using vanilla Laravel?
Ok, so which part exactly you need to help with? It's not something I can answer in a comment, and I can't create a full new course for you for all booking mechanism, I don't have that much free time available at the moment :)
How can I check those check_in and check_out dates that do not exists in the columns and store those dates using Eloquent or Query Builder? Your help is much appreciated, thank you so much! 🙏🙏
hello Mr. Povilas Korop,
I've tried to download this package but the issue was that my PHP version = 8.1.10. And it returned a big number of lists or errors.. I've tried other packages but still didn't work any of them (same issue..).
How can I resolve this issue? do you have a general approach for this and other packages with same kind of issue?
I want to store a booking in different dates that are not stored in the table already. How I disallow a user to make booking with same room in the same check-in and check out dates that is already booked? In other words, a room can be booked only once with different dates. I don't want to overlaps booking with same room with dates.
Here' what I have done so far :
publicfunctionstore(Request $request) { $request->validate(['check_in'=> ['required', 'date'],'check_out'=> ['required', 'date'],'amount'=> ['numeric'], ]);if (DB::table('booking_room')->where('room_id', $request->room_id)->exists()) {returnto_route('rooms')->with('error', 'Sorry! The room is already booked!'); }if (Auth::user()->is_verified ===false) {returnback()->with('error', 'Sorry! Your account is not verified, please call us to do so.'); }// Days based on check in & check out $check_in =Carbon::parse($request->check_in);// abort if user check-ins in the pastif ($check_in->lessThan(today())) {returnback()->with('error', 'Sorry! you cannot check-in the past.'); } $check_out =Carbon::parse($request->check_out); $days = $check_out->diffInDays($check_in);// Rounding up to 1 if user chooses the same date $days = $days ==0?1: $days;// Total price $room =Room::find($request->room_id); $price = $room->price; $total = $days * $price;// Total amount with discount $discount_amount =\Auth::user()->discount->percentage; $amount = $total - ($total * ($discount_amount /100)); $booking =Booking::create(['check_in'=> $check_in,'check_out'=> $check_out,'amount'=> $amount,'user_id'=>\Auth::id(), ]);// booking_idAuth::user()->bookings();// room_id $booking->rooms()->attach($request->room_id, ['status'=> (bool) false]);returnto_route('user.dashboard')->with('success', 'Booked! Please pay the invoice to get confirmed.'); }
I have done a mess here, I don't like this code at all and don't know how to write the logic:
if (DB::table('booking_room')->where('room_id', $request->room_id)->exists()) {returnto_route('rooms')->with('error', 'Sorry! The room is already booked!'); }
Dear Povilas,
I have imlemented the lessons learned from your course "[Mini-Course] Laravel Breeze with User Role Areas". I am building a project for a client. How can I implement a simple room booking system without using any fancy tools such as Alpine.js, Livewire, Packages or any frontend frameworks but just using vanilla Laravel?
I have
rooms
table with following columns:I need to insert the
room_id
intobookings
table like this:I have showed every rooms in the
index
page:From there user can view the room and book using a button.
I know this needs entire CRUD operations and time for a course. Your help is highly appreciated. Thank you! 🙏🙏
Ok, so which part exactly you need to help with? It's not something I can answer in a comment, and I can't create a full new course for you for all booking mechanism, I don't have that much free time available at the moment :)
I have stored the following row in my
bookings
tableHow can I check those
check_in
andcheck_out
dates that do not exists in the columns and store those dates using Eloquent or Query Builder? Your help is much appreciated, thank you so much! 🙏🙏Sorry, I don't really understand your question: you want me to explain how to do
Booking::where('check_in', $someVariable)
?hello Mr. Povilas Korop, I've tried to download this package but the issue was that my PHP version = 8.1.10. And it returned a big number of lists or errors.. I've tried other packages but still didn't work any of them (same issue..). How can I resolve this issue? do you have a general approach for this and other packages with same kind of issue?
This package is really old and not updated for latest PHP versions, unfortunately we don't have plans to update it, at the moment.
I want to store a booking in different dates that are not stored in the table already. How I disallow a user to make booking with same room in the same check-in and check out dates that is already booked? In other words, a room can be booked only once with different dates. I don't want to overlaps booking with same room with dates.
Here' what I have done so far :
I have done a mess here, I don't like this code at all and don't know how to write the logic:
I think my recent post may help you here: https://laraveldaily.com/post/laravel-custom-validation-rule-with-date-period-and-multiple-fields
Hi, This is one of my favourite projects. Are there any plans to upgrade to laravel 10 or 11? Thanks
Hi, we might upgrade this, but there is no ETA on when. We are slowly working over all the courses we had (prioritizing text ones for now)