Skip to content
Adrian Cole Adrian Cole

Laravel

Building a Booking System in Laravel Without Double Bookings

A practical look at slot generation, database locks and the status workflow that keeps a booking calendar honest.

·1 min read #Laravel#Booking#MySQL

Why double bookings happen

Most booking bugs come from a simple race: two visitors see the same free slot and submit at the same time. Checking availability in the controller is not enough.

The pattern that works

  1. Generate slots from configuration (working days, hours, interval, service duration).
  2. Filter out slots that overlap existing active bookings.
  3. On submit, acquire a lock for the date, re-check inside a database transaction, then insert.
$lock = Cache::lock('booking-date-'.$date, 15);
$lock->block(5);
DB::transaction(function () use ($date, $time) {
    // re-check overlap with lockForUpdate()
    Booking::create([...]);
});

Statuses matter

Use pending, confirmed, completed and cancelled. Only non-cancelled bookings should block a slot. When an admin cancels, the slot becomes available again automatically.

Email is part of the product

Send a receipt immediately, then notify the client when the status changes. People trust systems that communicate.

Need help with a Laravel project?

Let's talk about how I can help.

Book a call

Keep reading