PHPackages                             cheesytech/booking - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. cheesytech/booking

ActiveLibrary

cheesytech/booking
==================

A flexible and powerful booking system for Laravel applications

v1.1.0(2mo ago)31MITPHPPHP ^8.1CI passing

Since Jun 18Pushed 2mo agoCompare

[ Source](https://github.com/CheesyTech/booking)[ Packagist](https://packagist.org/packages/cheesytech/booking)[ Docs](https://github.com/cheesytech/booking)[ RSS](/packages/cheesytech-booking/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (20)Versions (4)Used By (0)

[![Packagist Version](https://camo.githubusercontent.com/d464f3ee4888b21659369eff78580c05bc9db0009b5177edd4d757a79f97874a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636865657379746563682f626f6f6b696e67)](https://camo.githubusercontent.com/d464f3ee4888b21659369eff78580c05bc9db0009b5177edd4d757a79f97874a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636865657379746563682f626f6f6b696e67)[![PHP Version](https://camo.githubusercontent.com/351755b1ea3b8a079461d461cd8142582eb91df14fea214307a660632576b07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d626c7565)](https://camo.githubusercontent.com/351755b1ea3b8a079461d461cd8142582eb91df14fea214307a660632576b07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d626c7565)[![Laravel](https://camo.githubusercontent.com/9bae2d9be2f5ba784143b82eae0b083e86e830cdaa9e751e8205adb30d882814/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3130253230253743253230313125323025374325323031322d726564)](https://camo.githubusercontent.com/9bae2d9be2f5ba784143b82eae0b083e86e830cdaa9e751e8205adb30d882814/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3130253230253743253230313125323025374325323031322d726564)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)[![Tests](https://github.com/cheesytech/booking/actions/workflows/tests.yml/badge.svg)](https://github.com/cheesytech/booking/actions/workflows/tests.yml/badge.svg)[![codecov](https://camo.githubusercontent.com/3b00242f6836256f7af1884d47e0acc6a85748361d1c74082b153a3d395ef6a0/68747470733a2f2f636f6465636f762e696f2f67682f636865657379746563682f626f6f6b696e672f67726170682f62616467652e7376673f746f6b656e3d4a385236434f41344b55)](https://codecov.io/gh/cheesytech/booking)

Laravel Booking
===============

[](#laravel-booking)

A flexible and powerful booking system for Laravel applications that supports polymorphic relationships, time slot management, and advanced status tracking.

Features
--------

[](#features)

- 🕒 Time slot management with overlap prevention
- 🔄 Polymorphic relationships for bookable and bookerable resources
- ⚙️ Configurable validation and overlap rules
- 🎯 Custom booking rules via OverlapRule interface
- 📅 Business hours and custom rules validation
- 🔒 Booking duration and minimum interval limits
- 🎨 Easy to extend with traits and interfaces
- 📊 Status tracking with full history and metadata
- 🔄 Event-driven architecture (BookingCreated, BookingUpdated, etc.)
- 🧪 Comprehensive testing support and model factories
- 🔍 Advanced querying and duration-based scopes (cross-DB)
- 💾 Multi-database support (MySQL, PostgreSQL, SQLite, SQL Server)
- ⏱️ Flexible duration calculations (minutes, hours, days)
- 🛠️ Publishable config and migration files

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0, 11.0, or 12.0
- Carbon 2.0 or higher

Installation
------------

[](#installation)

1. Install the package via composer:

```
composer require cheesytech/booking
```

2. The package will automatically register its service provider.
3. Publish and run the migrations:

```
php artisan vendor:publish --provider="CheeasyTech\Booking\BookingServiceProvider" --tag="migrations"
php artisan migrate
```

4. Publish the configuration file:

```
php artisan vendor:publish --provider="CheeasyTech\Booking\BookingServiceProvider" --tag="config"
```

Or use the install command for all at once:

```
php artisan package:install cheesytech/booking
```

This will create a `config/booking.php` file in your config directory.

Configuration
-------------

[](#configuration)

The package is highly configurable through the `config/booking.php` file. Example:

```
return [
    'statuses' => [
        'pending' => [
            'label' => 'Pending',
            'color' => '#FFA500',
            'can_transition_to' => ['confirmed', 'cancelled'],
        ],
        'confirmed' => [
            'label' => 'Confirmed',
            'color' => '#008000',
            'can_transition_to' => ['cancelled', 'completed'],
        ],
        'cancelled' => [
            'label' => 'Cancelled',
            'color' => '#FF0000',
            'can_transition_to' => [],
        ],
        'completed' => [
            'label' => 'Completed',
            'color' => '#0000FF',
            'can_transition_to' => [],
        ],
    ],
    'overlap' => [
        'enabled' => true,
        'allow_same_booker' => false,
        'min_time_between' => 0,
        'max_duration' => 0,
        'rules' => [
            'business_hours' => [
                'enabled' => false,
                'class' => \CheeasyTech\Booking\Rules\BusinessHoursRule::class,
            ],
        ],
    ],
    'events' => [
        'enabled' => true,
        'classes' => [
            'created' => \CheeasyTech\Booking\Events\BookingCreated::class,
            'updated' => \CheeasyTech\Booking\Events\BookingUpdated::class,
            'deleted' => \CheeasyTech\Booking\Events\BookingDeleted::class,
            'status_changed' => \CheeasyTech\Booking\Events\BookingStatusChanged::class,
        ],
    ],
];
```

Model Setup
-----------

[](#model-setup)

Implement the provided interfaces and use the traits for your models:

```
use CheeasyTech\Booking\Contracts\Bookable;
use CheeasyTech\Booking\Traits\HasBookings;
use Illuminate\Database\Eloquent\Model;

class Room extends Model implements Bookable {
    use HasBookings;
    // ...
    public function getBookableId(): int { return $this->id; }
    public function getBookableType(): string { return static::class; }
}

use CheeasyTech\Booking\Contracts\Bookerable;
use CheeasyTech\Booking\Traits\HasBookers;

class User extends Model implements Bookerable {
    use HasBookers;
    // ...
    public function getBookerableId(): int|string { return $this->id; }
    public function getBookerableType(): string { return static::class; }
}
```

Quick Start
-----------

[](#quick-start)

```
use CheeasyTech\Booking\Models\Booking;
use Carbon\Carbon;

$room = Room::find(1);
$user = User::find(1);

$booking = new Booking();
$booking->bookable()->associate($room);
$booking->bookerable()->associate($user);
$booking->start_time = Carbon::tomorrow()->setHour(10);
$booking->end_time = Carbon::tomorrow()->setHour(11);
$booking->status = 'pending';
$booking->save();

// Change booking status
$booking->changeStatus('confirmed', 'Approved by admin', ['key' => 'value']);

// Check for overlap
$isAvailable = !$booking->hasOverlap(
    Carbon::tomorrow()->setHour(10),
    Carbon::tomorrow()->setHour(11)
);
```

Traits &amp; Interfaces
-----------------------

[](#traits--interfaces)

- **HasBookings**: Add to bookable models (e.g., Room) for convenient booking management (`newBooking`, `deleteBooking`, etc.).
- **HasBookers**: Add to bookerable models (e.g., User) for managing bookings made by the entity.
- **Bookable**: Interface for resources to be booked (must implement `getBookableId`, `getBookableType`).
- **Bookerable**: Interface for entities making bookings (must implement `getBookerableId`, `getBookerableType`).
- **OverlapRule**: Interface for custom overlap validation rules.

Database Schema
---------------

[](#database-schema)

The package creates the following database table:

```
Schema::create('bookings', function (Blueprint $table) {
    $table->id();
    $table->morphs('bookable');
    $table->morphs('bookerable');
    $table->dateTime('start_time');
    $table->dateTime('end_time');
    $table->string('status')->default('pending');
    $table->json('status_history')->nullable();
    $table->timestamp('status_changed_at')->nullable();
    $table->timestamps();
});
```

Advanced Usage
--------------

[](#advanced-usage)

### Query Scopes

[](#query-scopes)

```
// Get bookings longer than 2 hours
Booking::durationLongerThan(120)->get();
// Get bookings between 1 and 2 hours
Booking::durationBetween(60, 120)->get();
// Combine with other conditions
Booking::durationLongerThan(120)->where('status', 'confirmed')->get();
```

### Status Management

[](#status-management)

```
$booking->changeStatus('confirmed', 'Approved by supervisor', ['approver_id' => 123]);
$status = $booking->getCurrentStatus();
$history = $booking->getStatusHistory();
if ($booking->hasStatus('confirmed')) { /* ... */ }
```

### Overlap &amp; Custom Rules

[](#overlap--custom-rules)

- Prevents overlapping bookings by default.
- Supports minimum interval and max duration.
- Add custom rules by implementing `OverlapRule` and registering in config.
- Example: BusinessHoursRule restricts bookings to business hours.

### Events

[](#events)

Events are fired for all major actions:

- BookingCreated
- BookingUpdated
- BookingDeleted
- BookingStatusChanged

### Testing &amp; Factories

[](#testing--factories)

Use provided factories for testing:

```
$booking = Booking::factory()->pending()->create();
$room = Room::factory()->create();
$user = User::factory()->create();
```

Updating PHPDoc
---------------

[](#updating-phpdoc)

To update PHPDoc for models, run:

```
./update-phpdoc.sh
```

Contributing
------------

[](#contributing)

Thank you for considering contributing to the Laravel Booking package! Please feel free to submit pull requests or create issues for bugs and feature requests.

License
-------

[](#license)

The Laravel Booking package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance86

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~261 days

Total

2

Last Release

73d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e5973f369c9aef0edc3b472a383b9b6e388896381161a6ad71f147b488bf908?d=identicon)[CheesyTech](/maintainers/CheesyTech)

---

Top Contributors

[![CheesyTech](https://avatars.githubusercontent.com/u/55180771?v=4)](https://github.com/CheesyTech "CheesyTech (18 commits)")

---

Tags

bookinglaravelphpschedulerlaravelcalendarappointmentsbookingreservation

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cheesytech-booking/health.svg)

```
[![Health](https://phpackages.com/badges/cheesytech-booking/health.svg)](https://phpackages.com/packages/cheesytech-booking)
```

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k21.5M159](/packages/laravel-octane)[laravel/nightwatch

The official Laravel Nightwatch package.

3486.1M13](/packages/laravel-nightwatch)[laraveljutsu/zap

A flexible, performant, and developer-friendly schedule management system for Laravel

1.4k69.1k](/packages/laraveljutsu-zap)[guava/calendar

Adds support for vkurko/calendar to Filament PHP.

298241.0k3](/packages/guava-calendar)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
