Managing schedules in web applications—whether for appointments, availability, or recurring events—can be a complex task. If you’re building with Laravel, there’s a powerful solution that simplifies it all: Laravel Zap. This package brings elegant, fluent scheduling capabilities to your Laravel models, making it ideal for booking systems, shift planners, and availability calendars.
In this post, we’ll explore how to integrate Laravel Zap into your project, create schedules, enforce business rules, and query availability—all with clean, expressive code.
🔍 What Is Laravel Zap?
Laravel Zap is a modern scheduling engine designed for Laravel 11+. It allows you to attach schedules to any Eloquent model, define recurrence patterns, detect conflicts, and enforce business rules—all while staying true to Laravel’s expressive syntax.
✅ Key Features
- Eloquent model integration
- Recurring schedules (daily, weekly, monthly)
- Conflict detection with buffer zones
- Working hours enforcement
- Fluent API for intuitive chaining
- Availability slot generation
- Metadata support for custom attributes
⚙️ Installation & Setup
Install Laravel Zap via Composer:
composer require laraveljutsu/zap
Publish and run migrations:
php artisan vendor:publish --tag=zap-migrations
php artisan migrate
Publish the config file:
php artisan vendor:publish --tag=zap-config
Add the HasSchedules trait to your model:
use Zap\Models\Concerns\HasSchedules;
class Doctor extends Model {
use HasSchedules;
}
🗓️ Creating Schedules
Basic Schedule
use Zap\Facades\Zap;
$doctor = Doctor::find(1);
Zap::for($doctor)
->named('Consultation')
->description('General health checkup')
->from('2025-09-15')
->addPeriod('10:00', '11:00')
->save();
Recurring Weekly Schedule
Zap::for($doctor)
->named('Weekly Checkup')
->from('2025-09-01')
->to('2025-12-31')
->addPeriod('09:00', '10:00')
->weekly(['monday', 'wednesday', 'friday'])
->save();
🧠 Enforcing Business Rules
Laravel Zap allows you to define rules like working hours, max duration, and overlap prevention.
Zap::for($doctor)
->named('VIP Appointment')
->from('2025-09-20')
->addPeriod('14:00', '16:00')
->noOverlap()
->workingHoursOnly('09:00', '18:00')
->maxDuration(120)
->withMetadata([
'room' => 'A1',
'priority' => 'high'
])
->save();
🔍 Availability & Conflict Detection
Check Availability
$doctor->isAvailableAt('2025-09-20', '14:00', '15:00');
Generate Available Time Slots
$doctor->getAvailableSlots(
date: '2025-09-20',
dayStart: '09:00',
dayEnd: '17:00',
slotDuration: 60
);
Detect Conflicts
Zap::findConflicts($schedule);
💡 Use Cases
Laravel Zap is perfect for:
- Doctor appointment systems
- Employee shift planners
- Meeting room reservations
- Event scheduling platforms
- Coaching or tutoring sessions
🧾 Final Thoughts
Laravel Zap brings clarity and control to schedule management in Laravel applications. With its fluent API, robust rule engine, and deep Eloquent integration, it’s a must-have for developers building time-sensitive platforms.
Whether you’re managing doctor appointments, employee shifts, or event bookings, Laravel Zap helps you build smarter, faster, and cleaner.
Fuel my creative spark with a virtual coffee! Your support keeps the ideas percolating—grab me a cup at Buy Me a Coffee and let’s keep the magic brewing!
