c4uno / carbon-business
A manager to work business date that can use the database to add extra dates
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
Class to manipulate the business dates. Compatible with Laravel 5., 7. and Lumen.
The version 2 require php 7.3
Install
composer require c4uno/carbon-business
Laravel < 5.3
Add service provider to config/app.php
C4uno\CarbonBusiness\Providers\LaravelServiceProvider::class,
Publish migrations and configuration
php artisan vendor:publish --provider="C4uno\CarbonBusiness\Providers\LaravelServiceProvider"
Lumen
Add service provider to bootstrap/app.php
$app->register(C4uno\CarbonBusiness\Providers\LumenServiceProvider::class);
< 5.3
Copy the migration the migration files. If is necessary copy the configuration file manually.
Use
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'
Testing
composer run-script tests
Development
You need to pass the tests composer run-script tests
script and write test to each new feature
that you write.