Getting Started

Installation

Get started with Laravel Zap.

Local development

Install Package

Use the composer CLI command to install Laravel Zap in a Laravel application:

Terminal
composer require laraveljutsu/zap

Setup Database

Publish and run the migrations to set up the required database tables:

Terminal
# Publish and run migrations
php artisan vendor:publish --tag=zap-migrations
php artisan migrate
Before installing and preparing your models, ensure that schedules and schedule_periods tables, as well as Schedule and SchedulePeriod models, do not already exist in your project to avoid conflicts.

Publish Configuration (Optional)

If you need to customize the package configuration, publish the config file:

Terminal
# Publish configuration file
php artisan vendor:publish --tag=zap-config

Add Trait to Models

Add the HasSchedules trait to any model that should support scheduling:

User.php
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zap\Models\Concerns\HasSchedules;

class User extends Authenticatable
{
    use HasSchedules;
}

Quick Start Example

Once installed, you can immediately start creating schedules using Laravel Zap's fluent API:

Basic Schedule

Example
use Zap\Facades\Zap;

// Create a simple appointment
$schedule = Zap::for($user)
    ->named('Doctor Appointment')
    ->description('Annual checkup')
    ->on('2025-03-15') // on() is an alias of from()
    ->addPeriod('09:00', '10:00')
    ->save();

Recurring Schedule

Example
// Weekly team meeting
$meeting = Zap::for($user)
    ->named('Team Standup')
    ->from('2025-01-01')
    ->to('2025-12-31')
    ->addPeriod('09:00', '09:30')
    ->weekly(['monday', 'wednesday', 'friday'])
    ->save();

Check Availability

Example
// Check if user is available
$available = $user->isAvailableAt('2025-03-15', '14:00', '16:00');

if ($available) {
    // User is free, proceed with booking
    echo "User is available!";
}

Getting Started with Documentation

Once the installation is complete, you can start using Laravel Zap's scheduling features in your application. The package provides a comprehensive set of tools for managing schedules and recurring events.

If you want to give me a hand or a tip, let's connect!