定制 encoredigitalgroup/business-hours 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

encoredigitalgroup/business-hours

最新稳定版本:v0.1.2

Composer 安装命令:

composer require encoredigitalgroup/business-hours

包简介

无描述信息

README 文档

README

Business Hours is a PHP library that provides a type-safe wrapper around spatie/opening-hours and cmixin/business-day. It allows you to manage business hours, holidays, and exceptions in a robust, object-oriented way.

Features

  • Type-safe configuration of business hours for each day of the week
  • Support for holidays and exceptions
  • Integration with Spatie OpeningHours and BusinessDay for advanced time calculations

Requirements

  • PHP 8.3 or higher

Installation

Install via Composer:

composer require encoredigitalgroup/business-hours

Usage

Basic Setup

use EncoreDigitalGroup\BusinessHours\BusinessHours; $config = BusinessHours::config();

Configuring Business Hours

Below is an example of how to set business hours and how to set exceptions to those business hours.

use EncoreDigitalGroup\StdLib\Objects\Calendar\DayOfWeek; use Carbon\Carbon; #You can also use Illuminate\Support\Carbon // Set Monday hours $config->day(DayOfWeek::Monday)->addHours("09:00", "17:00"); // Set exceptions $config->exceptions()->adjustedHours(Carbon::parse("2025-07-04"), "08:00", "14:00:", "4th of July"); $config->exceptions()->closed(Carbon::parse("2025-12-25"), "Christmas Day");

Adding Holidays

Below is an example of how to create and configure a holiday. When creating the holiday, the library will automatically register the date as a closed exception.

use Carbon\Carbon; $config->holidays()->region("global")->add(Carbon::parse("2025-12-25"), "christmas", "Christmas Day", true);

Checking If a Date Is a Holiday

use Carbon\Carbon; Carbon::parse("2025-12-25")->isHoliday(); // true

Testing

This project uses PestPHP for testing. To run the test suite:

vendor/bin/pest

Contributing

Contributions are welcome! Please submit pull requests and ensure all tests pass.

License

License information can be found in the LICENSE.md file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固