sodecl/scheduler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sodecl/scheduler

最新稳定版本:v0.1.2

Composer 安装命令:

composer require sodecl/scheduler

包简介

Scheduler library

README 文档

README

Introduction

Sodecl Scheduler is a PHP library designed for creating and managing a customizable schedule of time slots. It's particularly useful for applications that require precise control over operational hours, appointments, breaks, and scheduling constraints. Leveraging the Carbon library for date and time manipulation, Sodecl Scheduler offers a powerful yet flexible way to handle complex scheduling needs.

Features

  • Flexible time slot configuration (e.g., 1 hour or 15 minutes blocks).
  • Customizable working days and operational hours.
  • Support for managing lunch breaks within the schedule.
  • Ability to exclude specific time slots.
  • Integration with Carbon for robust date and time handling.

Installation

To install the Sodecl Scheduler, you will need Composer, a dependency manager for PHP.

Run the following command in your project directory:

composer require sodecl/scheduler

Usage

Basic Setup

First, ensure you import the necessary classes from the library:

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

Schedule Configuration

Create a ScheduleConfig object to define your schedule parameters:

$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());

Creating a Schedule

Instantiate the Schedule class with your configuration:

$schedule = new Schedule($scheduleConfig);

Generating Time Slots

Generate time slots for a specific day:

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

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

Examples

Example 1: 1 Hour Time Blocks

This example demonstrates setting up a schedule with 1-hour blocks, excluding lunch hours:

$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());

Example 2: 15 Minute Time Blocks

In this example, the schedule is set for 15-minute time slots without a lunch break:

$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());

Contributing

Contributions to the Sodecl Scheduler are welcome. Please ensure to follow the project's code standards and submit your pull requests for review.

License

MIT

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固