Download the PHP package masterix21/laravel-bookings without Composer
On this page you can find all versions of the php package masterix21/laravel-bookings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download masterix21/laravel-bookings
More information about masterix21/laravel-bookings
Files in masterix21/laravel-bookings
Package laravel-bookings
Short Description Add bookings ability to any Eloquent model
License MIT
Homepage https://github.com/masterix21/laravel-bookings
Informations about the package laravel-bookings
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
- Features
- Requirements
- Installation
- Quick Start
- Core Concepts
- Advanced Features
- Documentation
- Testing
- Contributing & Credits
Features
- 🚀 Make any Eloquent model bookable with a single trait
- 📅 Advanced time period management powered by 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
| Requirement | Version |
|---|---|
| PHP | 8.3+ |
| Laravel | 12.x or 13.x |
Installation
Install the package via Composer:
Publish and run the migrations:
Optionally, publish the config file:
See the installation guide for optional migrations and upgrade notes.
Upgrading
Upgrading an existing installation? See the migration guide — it covers a required data cleanup step and a foreign key behavior change before you run php artisan migrate.
Quick Start
1. Make a model bookable
Add the IsBookable trait to any model:
2. Create its bookable resource
Create the BookableResource that defines availability and capacity. To keep it in sync with your model on every save, add the optional SyncBookableResource trait.
3. Make a booking
Overlapping bookings are rejected automatically:
See the getting started guide for a full walkthrough.
Core Concepts
| Concept | Description |
|---|---|
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
Each feature below is summarized here and documented in full under docs/.
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
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
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
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
Planning constraints
Define when a resource can be booked through BookablePlanning records — available weekdays plus starts_at/ends_at windows. → docs/models.md
Events
The booking lifecycle emits events (BookingInProgress, BookingCompleted, BookingFailed, BookingChanging, BookingChanged, BookingChangeFailed) for audit trails and integrations. → docs/events.md
Checking availability
Documentation
| Guide | Description |
|---|---|
| Getting Started | Step-by-step quick start |
| Installation | Installation and optional migrations |
| Configuration | Configurable models and generators |
| Architecture | Package design and structure |
| Models | Model relationships and usage |
| Actions | Core booking operations |
| Synchronization | Resource and planning synchronization |
| Events | Event system and listeners |
| Database Schema | Tables and migrations |
| API Reference | Complete API documentation |
| Migration Guide | Upgrading between versions |
| Extending | Customization and extension points |
| Troubleshooting | Common issues and solutions |
Examples
- 🏨 Hotel Booking System
- 🚗 Car Rental System
- 🍽️ Restaurant Reservations
- 📅 Service Appointments
Testing
See docs/testing.md for testing strategies.
Contributing & Credits
- Please see CONTRIBUTING for contribution guidelines.
- Please see CHANGELOG for recent changes.
- Report security vulnerabilities via our security policy.
Created and maintained by Luca Longo and all contributors.
License
The MIT License (MIT). See the License File for details.
All versions of laravel-bookings with dependencies
illuminate/contracts Version ^12.0 || ^13.0
kirschbaum-development/eloquent-power-joins Version ^4.2
nesbot/carbon Version ^3.8
spatie/laravel-package-tools Version ^1.92
spatie/period Version ^2.4
staudenmeir/belongs-to-through Version ^2.16
staudenmeir/eloquent-has-many-deep Version ^1.20