Laravel Zap logo
Guides

Schedule Patterns

Learn how to define recurring schedules and time periods.

Schedule Patterns

Recurrence

Zap supports flexible recurrence patterns.

$schedule = Zap::for($doctor)
    ->named('Office Hours')
    ->availability();

// Daily
$schedule->daily()->from('2025-01-01')->to('2025-12-31');

// Weekly (specific days)
$schedule->weekly(['monday', 'wednesday', 'friday'])->forYear(2025);

// Monthly
$schedule->monthly(['day_of_month' => 1])->forYear(2025);

Date Ranges

Define the validity period of a schedule.

$schedule = Zap::for($doctor)
    ->named('Office Hours')
    ->availability();

// Single date
$schedule->from('2025-01-15');

// Date range
$schedule->from('2025-01-01')->to('2025-12-31');

// Alternative syntax
$schedule->between('2025-01-01', '2025-12-31');

// Entire year shortcut
$schedule->forYear(2025);

Time Periods

Define the time slots within a day.

$schedule = Zap::for($doctor)
    ->named('Office Hours')
    ->availability();

// Single period
$schedule->addPeriod('09:00', '17:00');

// Multiple periods (split shifts)
$schedule->addPeriod('09:00', '12:00');
$schedule->addPeriod('14:00', '17:00');