- How do I set up Zap for appointment booking in a Laravel app?
- Install via Composer (`composer require laraveljutsu/zap`), publish the provider, run migrations, and add the `HasSchedules` trait to your model (e.g., `Doctor`). Then define availability windows, appointments, or blocked times using Zap’s fluent methods like `addAvailability()` or `blockTime()`.
- Does Zap support recurring schedules like weekly or monthly appointments?
- Yes, Zap includes 15+ recurrence rules (daily, weekly, monthly ordinals, custom intervals). Use methods like `recurs()->daily()->onWeekdays()` or `recurs()->monthly()->onLastDayOfMonth()` to define repeating schedules. All rules respect your app’s timezone.
- Can I use Zap with UUIDs or ULIDs instead of integer primary keys?
- Zap supports UUID/ULID but requires extra configuration. You’ll need to modify the migrations and update the `schedulable_id` column type in the `schedule_periods` table. The documentation provides a step-by-step guide for this setup.
- How does Zap handle overlapping appointments or blocked times?
- Zap provides built-in conflict detection with methods like `noOverlap()` and `maxDuration()`. When creating or querying schedules, it automatically checks for overlaps and enforces your rules. You can also customize overlap behavior for specific use cases.
- What Laravel versions does Zap support, and is it compatible with PHP 8.5+?
- Zap requires Laravel 13.0+ and PHP 8.5+. It’s designed for modern Laravel stacks and includes minimal version constraints. Always check the latest release notes for any breaking changes or new feature requirements.
- Can I query available time slots for a resource (e.g., a doctor or meeting room)?
- Yes, Zap offers methods like `getBookableSlots()` and `isBookableAtTime()` to check availability. You can also use `schedulesForDateRange()` to fetch all appointments or blocked times within a specific period, making it easy to build a frontend calendar.
- Does Zap work with soft deletes in Laravel models?
- No, Zap does not natively support soft deletes. If your models use `SoftDeletes`, you’ll need to extend the `Schedule` model to include soft delete logic manually. The package documentation provides guidance on implementing this workaround.
- Are there any alternatives to Zap for Laravel scheduling?
- Yes, alternatives include `spatie/laravel-schedule` (for cron jobs) or `spatie/laravel-calendar` (for event calendars). However, Zap is specialized for resource booking, appointment systems, and shift management with built-in overlap rules and recurrence patterns.
- How do I test Zap’s scheduling logic in my Laravel app?
- Use Laravel’s testing tools to create mock models with the `HasSchedules` trait, then test methods like `addAvailability()`, `blockTime()`, and `isBookableAtTime()`. You can also test recurrence rules by verifying schedules are generated correctly for edge cases like holidays or custom intervals.
- Can Zap handle multi-resource dependencies (e.g., booking a room *and* an AV technician)?
- Zap is designed for single-resource scheduling (e.g., a doctor, room, or employee). For multi-resource dependencies, you’ll need to implement custom logic, such as querying multiple models sequentially or using Laravel’s queue system to coordinate bookings across resources.