PHPackages                             masterix21/laravel-bookings - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. masterix21/laravel-bookings

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

masterix21/laravel-bookings
===========================

Add bookings ability to any Eloquent model

1.3.0(1mo ago)5691MITPHPPHP ^8.4CI passing

Since Nov 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/masterix21/laravel-bookings)[ Packagist](https://packagist.org/packages/masterix21/laravel-bookings)[ Docs](https://github.com/masterix21/laravel-bookings)[ GitHub Sponsors](https://github.com/lucalongo)[ RSS](/packages/masterix21-laravel-bookings/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (38)Versions (15)Used By (0)

Laravel Bookings
================

[](#laravel-bookings)

[![Latest Version on Packagist](https://camo.githubusercontent.com/155d9734b231e4c2dc10750f32dcab37bcf873034fc42f807559d83983cc166d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6173746572697832312f6c61726176656c2d626f6f6b696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-bookings)[![Tests](https://camo.githubusercontent.com/9af49dcf2ba4ce39aff6b69b19bb63a8c2545fa2b6291ae9ab21e54345eb672e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6173746572697832312f6c61726176656c2d626f6f6b696e67732f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/masterix21/laravel-bookings/actions/workflows/run-tests.yml)[![PHP Version](https://camo.githubusercontent.com/814e9769d54291b00a2c9c996adf1fc279b0460ac3d118f46e8778973da0c8dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6173746572697832312f6c61726176656c2d626f6f6b696e67733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-bookings)[![Total Downloads](https://camo.githubusercontent.com/eeaf20f95db863993c23804c708c2eb518b93bf92db96318836944a9a7d64d6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6173746572697832312f6c61726176656c2d626f6f6b696e67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/masterix21/laravel-bookings)

Add booking functionality to any Eloquent model. Turn your models into bookable resources with time-based reservations, capacity management, planning constraints, overlap detection, and an event-driven architecture.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Core Concepts](#core-concepts)
- [Advanced Features](#advanced-features)
- [Documentation](#documentation)
- [Testing](#testing)
- [Contributing &amp; Credits](#contributing--credits)

Features
--------

[](#features)

- 🚀 **Make any Eloquent model bookable** with a single trait
- 📅 **Advanced time period management** powered by [spatie/period](https://github.com/spatie/period)
- 🏢 **Resource capacity control** with configurable concurrency limits
- 📋 **Planning constraints** for weekday and time-window restrictions
- 🔍 **Overlap detection** and conflict prevention
- 🎯 **Event-driven architecture** for audit trails and integrations
- 🗂️ **Polymorphic relationships** for flexible booker and resource types
- 🔗 **Related bookings** with parent-child relationships
- 🔄 **Automatic synchronization** of resources and planning via model events
- 🛡️ **Transaction safety** with automatic rollback on failures

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

[](#requirements)

RequirementVersionPHP8.4+Laravel12.x or 13.xInstallation
------------

[](#installation)

Install the package via Composer:

```
composer require masterix21/laravel-bookings
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="bookings-migrations"
php artisan migrate
```

Optionally, publish the config file:

```
php artisan vendor:publish --tag="bookings-config"
```

See the [installation guide](docs/installation.md) for optional migrations and upgrade notes.

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

[](#quick-start)

### 1. Make a model bookable

[](#1-make-a-model-bookable)

Add the `IsBookable` trait to any model. A `BookableResource` is created and kept in sync automatically.

```
use Masterix21\Bookings\Models\Concerns\Bookable;
use Masterix21\Bookings\Models\Concerns\IsBookable;

class Room extends Model implements Bookable
{
    use IsBookable;

    protected $fillable = ['name', 'capacity'];
}
```

### 2. Configure the bookable resource

[](#2-configure-the-bookable-resource)

Each bookable model exposes its `BookableResource`, where you set availability and capacity:

```
$room = Room::create(['name' => 'Deluxe Suite', 'capacity' => 4]);

$room->bookableResource->update([
    'max' => 1,            // Maximum concurrent bookings
    'size' => 4,           // Resource capacity
    'is_bookable' => true,
    'is_visible' => true,
]);
```

### 3. Make a booking

[](#3-make-a-booking)

```
use Masterix21\Bookings\Actions\BookResource;
use Spatie\Period\Period;
use Spatie\Period\PeriodCollection;

$periods = PeriodCollection::make([
    Period::make('2024-12-25', '2024-12-27'),
]);

$booking = (new BookResource())->run(
    periods: $periods,
    bookableResource: $room->bookableResource,
    booker: auth()->user(),
    label: 'Christmas Holiday',
    meta: ['guests' => 2],
);
```

Overlapping bookings are rejected automatically:

```
use Masterix21\Bookings\Exceptions\BookingResourceOverlappingException;

try {
    $booking = (new BookResource())->run(/* ... */);
} catch (BookingResourceOverlappingException $e) {
    return response()->json(['error' => 'Time slot already booked'], 409);
}
```

See the [getting started guide](docs/getting-started.md) for a full walkthrough.

Core Concepts
-------------

[](#core-concepts)

ConceptDescription`BookableResource`The bookable item, linked to your model (Room, Car, …) via a polymorphic relation.`Booking`A reservation with booker, metadata, and one or more time periods.`BookedPeriod`An individual time slot within a booking, enabling multi-period reservations.`BookablePlanning`Availability rules: working days, time windows, and constraints for a resource.Advanced Features
-----------------

[](#advanced-features)

Each feature below is summarized here and documented in full under [`docs/`](docs/).

### Booking lifecycle callbacks

[](#booking-lifecycle-callbacks)

Hook custom logic before and after a booking is persisted with `onBookingSaving()` and `onBookingSaved()` — useful for multi-tenancy, logging, or side effects. → [docs/actions.md](docs/actions.md#booking-lifecycle-callbacks)

### Custom resource synchronization

[](#custom-resource-synchronization)

Add the `SyncBookableResource` trait and implement `syncBookableResource()` to push data from your model (visibility, capacity, availability) into its `BookableResource` automatically on save. → [docs/synchronization.md](docs/synchronization.md)

### Planning source pattern

[](#planning-source-pattern)

Add the `SyncBookablePlanning` trait so a business model (rate, special offer, seasonal rule) becomes the single source of truth for a resource's availability, with bidirectional navigation between source and planning. → [docs/synchronization.md](docs/synchronization.md)

### Related bookings

[](#related-bookings)

Link bookings with parent-child relationships (room + parking, appointment + follow-up). Each booking keeps an independent lifecycle, and children survive parent deletion. Requires an optional migration. → [docs/related-bookings.md](docs/related-bookings.md)

### Planning constraints

[](#planning-constraints)

Define when a resource can be booked through `BookablePlanning` records — available weekdays plus `starts_at`/`ends_at` windows. → [docs/models.md](docs/models.md)

### Events

[](#events)

The booking lifecycle emits events (`BookingInProgress`, `BookingCompleted`, `BookingFailed`, `BookingChanging`, `BookingChanged`, `BookingChangeFailed`) for audit trails and integrations. → [docs/events.md](docs/events.md)

### Checking availability

[](#checking-availability)

```
$room->isBookedAt(now());            // bool
$room->bookedPeriodsOfDate(today()); // booked periods for a date
$room->bookings;                     // all bookings for the resource
```

Documentation
-------------

[](#documentation)

GuideDescription[Getting Started](docs/getting-started.md)Step-by-step quick start[Installation](docs/installation.md)Installation and optional migrations[Configuration](docs/configuration.md)Configurable models and generators[Architecture](docs/architecture.md)Package design and structure[Models](docs/models.md)Model relationships and usage[Actions](docs/actions.md)Core booking operations[Synchronization](docs/synchronization.md)Resource and planning synchronization[Events](docs/events.md)Event system and listeners[Database Schema](docs/database-schema.md)Tables and migrations[API Reference](docs/api-reference.md)Complete API documentation[Migration Guide](docs/migration-guide.md)Upgrading between versions[Extending](docs/extending.md)Customization and extension points[Troubleshooting](docs/troubleshooting.md)Common issues and solutions### Examples

[](#examples)

- 🏨 [Hotel Booking System](docs/examples/hotel-booking.md)
- 🚗 [Car Rental System](docs/examples/car-rental.md)
- 🍽️ [Restaurant Reservations](docs/examples/restaurant-reservations.md)
- 📅 [Service Appointments](docs/examples/service-appointments.md)

Testing
-------

[](#testing)

```
composer test           # run the test suite
composer test-coverage  # run with coverage
composer analyse        # run static analysis (PHPStan)
```

See [docs/testing.md](docs/testing.md) for testing strategies.

Contributing &amp; Credits
--------------------------

[](#contributing--credits)

- Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for contribution guidelines.
- Please see [CHANGELOG](CHANGELOG.md) for recent changes.
- Report security vulnerabilities via [our security policy](../../security/policy).

Created and maintained by [Luca Longo](https://github.com/masterix21) and [all contributors](../../contributors).

License
-------

[](#license)

The MIT License (MIT). See the [License File](LICENSE.md) for details.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 92.1% 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 ~69 days

Recently: every ~55 days

Total

9

Last Release

45d ago

Major Versions

0.0.2 → 1.0.02025-07-28

PHP version history (3 changes)0.0.1PHP ^8.3

0.0.2PHP ^8.3|^8.4

1.1.1PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/177020fc4adb5c08acee3e6fe0b65002a96665c5d5c522a3ef009b4105fd634f?d=identicon)[masterix](/maintainers/masterix)

---

Top Contributors

[![masterix21](https://avatars.githubusercontent.com/u/6555012?v=4)](https://github.com/masterix21 "masterix21 (197 commits)")[![mikugrunge](https://avatars.githubusercontent.com/u/44170111?v=4)](https://github.com/mikugrunge "mikugrunge (17 commits)")

---

Tags

LucaLongolaravel-bookings

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/masterix21-laravel-bookings/health.svg)

```
[![Health](https://phpackages.com/badges/masterix21-laravel-bookings/health.svg)](https://phpackages.com/packages/masterix21-laravel-bookings)
```

###  Alternatives

[illuminate/support

The Illuminate Support package.

630113.0M41.3k](/packages/illuminate-support)[filament/support

Core helper methods and foundation code for all Filament packages.

2331.0M245](/packages/filament-support)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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