// Office hours
Zap::for($doctor)
->named('Office Hours')
->availability()
->forYear(2025)
->weekly(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
->addPeriod('09:00', '12:00')
->addPeriod('14:00', '17:00')
->save();
// Lunch break
Zap::for($doctor)
->named('Lunch Break')
->blocked()
->forYear(2025)
->weekly(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
->addPeriod('12:00', '13:00')
->save();
// Book appointment
Zap::for($doctor)
->named('Patient A - Checkup')
->appointment()
->from('2025-01-15')
->addPeriod('10:00', '11:00')
->withMetadata(['patient_id' => 1])
->save();
// Get available slots
$slots = $doctor->getBookableSlots('2025-01-15', 60, 15);
// Room availability (using weekDays convenience method)
Zap::for($room)
->named('Conference Room A')
->availability()
->weekDays(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], '08:00', '18:00')
->forYear(2025)
->save();
// Book meeting
Zap::for($room)
->named('Board Meeting')
->appointment()
->from('2025-03-15')
->addPeriod('09:00', '11:00')
->withMetadata(['organizer' => 'john@company.com'])
->save();
// Regular schedule (using weekDays convenience method)
Zap::for($employee)
->named('Regular Shift')
->availability()
->weekDays(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], '09:00', '17:00')
->forYear(2025)
->save();
// Vacation
Zap::for($employee)
->named('Vacation Leave')
->blocked()
->between('2025-06-01', '2025-06-15')
->addPeriod('00:00', '23:59')
->save();
Perfect for employees who alternate between morning and afternoon shifts every other week:
// Employee works morning shift (5:00-13:00) on odd weeks
Zap::for($employee)
->named('Morning Shift - Odd Weeks')
->availability()
->weekOddDays(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], '05:00', '13:00')
->forYear(2025)
->save();
// Same employee works afternoon shift (13:00-21:00) on even weeks
Zap::for($employee)
->named('Afternoon Shift - Even Weeks')
->availability()
->weekEvenDays(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], '13:00', '21:00')
->forYear(2025)
->save();
When two people share an office and need to alternate weeks:
// Person A uses the office on odd weeks
Zap::for($personA)
->named('Office Access - Odd Weeks')
->availability()
->weeklyOdd(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
->addPeriod('09:00', '17:00')
->forYear(2025)
->save();
// Person B uses the office on even weeks
Zap::for($personB)
->named('Office Access - Even Weeks')
->availability()
->weeklyEven(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
->addPeriod('09:00', '17:00')
->forYear(2025)
->save();
// Bi-weekly team standup every other Monday
Zap::for($team)
->named('Team Standup')
->appointment()
->biweekly(['monday'])
->from('2025-01-06')
->to('2025-12-31')
->addPeriod('09:00', '09:30')
->save();
// Quarterly performance reviews on the 15th of every quarter
Zap::for($manager)
->named('Quarterly Reviews')
->blocked()
->quarterly(['days_of_month' => [15], 'start_month' => 1])
->from('2025-01-15')
->to('2025-12-15')
->addPeriod('10:00', '17:00')
->save();
// Monthly payroll on the 1st and 15th of each month
Zap::for($accountant)
->named('Payroll Processing')
->blocked()
->monthly(['days_of_month' => [1, 15]])
->forYear(2025)
->addPeriod('08:00', '12:00')
->save();
// Annual company meeting on April 1st and 15th
Zap::for($company)
->named('Annual Company Meeting')
->blocked()
->annually(['days_of_month' => [1, 15], 'start_month' => 4])
->from('2025-04-01')
->to('2026-04-15')
->addPeriod('09:00', '17:00')
->save();
If you store identifiers in metadata, you can fetch schedules that match them directly through the relation:
// Example: fetch all schedules for a given customer id
$schedules = $schedulable
->schedules()
->where('metadata->customer_id', $customerId)
->get();
This works for any metadata keys you persist via ->withMetadata([...]).