Laravel Zap logo
Guides

Configuration & Advanced

Customize Zap and use advanced features.

Configuration

Publish and customize the configuration file:

php artisan vendor:publish --tag=zap-config

Key settings in config/zap.php:

use Carbon\CarbonInterface;

return [
    'calendar' => [
        'week_start' => CarbonInterface::MONDAY,  // Week start day for bi-weekly calculations
    ],

    'time_slots' => [
        'buffer_minutes' => 0,  // Default buffer between slots
    ],

    'default_rules' => [
        'no_overlap' => [
            'enabled' => true,
            'applies_to' => ['appointment', 'blocked'],
        ],
    ],
];

Custom Model Support (UUIDs, ULIDs, GUIDs)

Zap assumes auto-incrementing integers by default. If you use UUID-style keys, customize the models and migrations before running them.

1) Extend the models

Create your own models that add Laravel's HasUuids trait:

use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Zap\Models\Schedule as BaseSchedule;
use Zap\Models\SchedulePeriod as BaseSchedulePeriod;

class Schedule extends BaseSchedule
{
    use HasUuids;
}

class SchedulePeriod extends BaseSchedulePeriod
{
    use HasUuids;
}

2) Update your schedulable model

use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Zap\Models\Concerns\HasSchedules;

class Doctor extends Model
{
    use HasSchedules, HasUuids;
}

3) Point config to your models

// config/zap.php
'models' => [
    'schedule' => \App\Models\Schedule::class,
    'schedule_period' => \App\Models\SchedulePeriod::class,
],

4) Update published migrations

// database/migrations/**_create_schedules_table.php
- $table->id();
- $table->morphs('schedulable');
+ $table->uuid('id')->primary();
+ $table->uuidMorphs('schedulable');

// database/migrations/**_create_schedule_periods_table.php
- $table->id();
- $table->foreignId('schedule_id')->constrained()->cascadeOnDelete();
+ $table->uuid('id')->primary();
+ $table->foreignUuid('schedule_id')->constrained()->cascadeOnDelete();

Adjust to ulid/guid helpers if you prefer those types. Make these changes before migrating so keys stay consistent across your app.

Advanced Features

Custom Schedules with Explicit Rules

Zap::for($user)
    ->named('Custom Event')
    ->custom()
    ->from('2025-01-15')
    ->addPeriod('15:00', '16:00')
    ->noOverlap()  // Explicitly prevent overlaps
    ->save();

Metadata Support

Attach arbitrary data to any schedule:

->withMetadata([
    'patient_id' => 1,
    'type' => 'consultation',
    'notes' => 'Follow-up required'
])