c4uno / carbon-business
一个用于处理业务日期的管理器,可以使用数据库添加额外的日期
2.0.10
2020-12-28 23:51 UTC
Requires
- php: ^7.4
- nesbot/carbon: 2.*
Requires (Dev)
- fzaninotto/faker: ^1.9.1
- mockery/mockery: ^1.4.1
- orchestra/testbench: ^5.3
- phpmd/phpmd: ^2.8.2
- phpstan/phpstan: ^0.12.18
- phpunit/phpunit: ^8.5
- squizlabs/php_codesniffer: ^3.5
Suggests
- friendsofphp/php-cs-fixer: Needed for the `composer phpcs` command. Allow to automatically fix code style.
- phpstan/phpstan: Needed for the `composer phpstan` command. Allow to detect potential errors.
README
用于操作业务日期的类。兼容Laravel 5., 7. 和 Lumen。
版本 2 需要 php 7.3
安装
composer require c4uno/carbon-business
Laravel < 5.3
将服务提供者添加到 config/app.php
C4uno\CarbonBusiness\Providers\LaravelServiceProvider::class,
发布迁移和配置
php artisan vendor:publish --provider="C4uno\CarbonBusiness\Providers\LaravelServiceProvider"
Lumen
将服务提供者添加到 bootstrap/app.php
$app->register(C4uno\CarbonBusiness\Providers\LumenServiceProvider::class);
< 5.3
复制迁移文件。如果需要,请手动复制配置文件。
使用
use C4uno\CarbonBusiness\Managers\CarbonBusiness;
use C4uno\CarbonBusiness\Contracts\HolidayRepository;
use Carbon\Carbon;
$manager = new CarbonBusiness(
app(HolidayRepository::class)
);
// Thurday
$date = Carbon::parse('2019-02-15');
$manager->isBusinessDay($date); // true, if the date is not in the DB.
$manager->addBusinessDay($date); // '2019-02-18', by default saturday and sunday are no-business day
$manager->subBusinesDay($date); // '2019-02-18'
测试
composer run-script tests
开发
你需要运行 composer run-script tests
脚本通过测试,并为每个新特性编写测试。