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'],
],
],
];
Zap assumes auto-incrementing integers by default. If you use UUID-style keys, customize the models and migrations before running them.
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;
}
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Zap\Models\Concerns\HasSchedules;
class Doctor extends Model
{
use HasSchedules, HasUuids;
}
// config/zap.php
'models' => [
'schedule' => \App\Models\Schedule::class,
'schedule_period' => \App\Models\SchedulePeriod::class,
],
// 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.
Zap::for($user)
->named('Custom Event')
->custom()
->from('2025-01-15')
->addPeriod('15:00', '16:00')
->noOverlap() // Explicitly prevent overlaps
->save();
Attach arbitrary data to any schedule:
->withMetadata([
'patient_id' => 1,
'type' => 'consultation',
'notes' => 'Follow-up required'
])