PHP code example of sodecl / scheduler

1. Go to this page and download the library: Download sodecl/scheduler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sodecl / scheduler example snippets


use Sodecl\Scheduler\Schedule;
use Sodecl\Scheduler\ScheduleConfig;
use Sodecl\Scheduler\TimeSlot;

$scheduleConfig = ScheduleConfig::make()
    ->openingHour('08:00')
    ->closingHour('17:00')
    ->lunchBreak()
    ->lunchBreakStart('12:00')
    ->lunchBreakDuration(60) // in minutes
    ->slotMinutes(60)
    ->days(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
    ->scheduleStart(now()->startOfMonth())
    ->scheduleEnd(now()->endOfMonth());

$schedule = new Schedule($scheduleConfig);

$date = today(); // Carbon instance for the date
$slotsTaken = []; // Array of TimeSlot objects representing booked slots

$timeSlots = $schedule->timeSlotsFor($date, $slotsTaken);

$scheduleConfig = ScheduleConfig::make()
    ->openingHour('08:00')
    ->closingHour('17:00')
    ->lunchBreak()
    ->lunchBreakStart('12:00')
    ->lunchBreakDuration(60) // in minutes
    ->slotMinutes(60)
    ->days(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
    ->scheduleStart(now()->startOfMonth())
    ->scheduleEnd(now()->endOfMonth());

$scheduleConfig = ScheduleConfig::make()
    ->openingHour('08:00')
    ->closingHour('17:00')
    ->lunchBreak()
    ->lunchBreakStart('12:00')
    ->lunchBreakDuration(60) // in minutes
    ->slotMinutes(15)
    ->days(['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
    ->scheduleStart(now()->startOfMonth())
    ->scheduleEnd(now()->endOfMonth());