c4uno/carbon-business

Carbon's extension to work with business days.

1.0.0 2019-02-15 18:57 UTC

This package is not auto-updated.

Last update: 2020-07-05 11:01:56 UTC


README

It add extra function to work with holidays. Compatible with Laravel 5.* and Lumen.

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\CarbonBusiness;

// Thurday
$date = CarbonBusiness::createFromCarbon(Carbon::parse('2019-02-15'));
$data->isBusinessDay(); // true, if the date is not in the DB.
$date->addBusinessDay(); // '2019-02-18', by default saturday and sunday are no-business day
$date->subBusinesDay; // '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.