artarts36/laravel-holiday

Your Package Description here

1.0.4 2021-04-28 21:50 UTC

This package is auto-updated.

Last update: 2021-09-28 22:36:24 UTC


README

With this package you can save dates of holidays or shortened days on your Laravel application.

Testing License: MIT Total Downloads

Install

Run command: composer require artarts36/laravel-holiday

Add Provider: ArtARTs36\LaravelHoliday\Providers\HolidayProvider

Run command: php artisan migrate

Run command: php artisan db:seed --class=HolidayDatabaseSeeder

Commands

Command Description
holiday:fetch current-year Holidays for the current year are saved
holiday:fetch current-month Holidays for the current month are saved

Examples

Determine work type by Day
$client = new \GuzzleHttp\Client([
    'base_uri' => 'https://isdayoff.ru/',
]);

$isDayOff = new \ArtARTs36\LaravelHoliday\Determiners\IsDayOff($client);

var_dump($isDayOff->determine(\Carbon\Carbon::parse('2020-11-04'))); // string(7) "weekend"
Determine work type by Period
$client = new \GuzzleHttp\Client([
    'base_uri' => 'https://isdayoff.ru/',
]);

$isDayOff = new \ArtARTs36\LaravelHoliday\Determiners\IsDayOff($client);

var_dump($isDayOff->determinePeriod(\Carbon\Carbon::parse('2020-11-04'), \Carbon\Carbon::parse('2020-12-15')));
Determine work type by Year
$client = new \GuzzleHttp\Client([
    'base_uri' => 'https://isdayoff.ru/',
]);

$isDayOff = new \ArtARTs36\LaravelHoliday\Determiners\IsDayOff($client);

var_dump($isDayOff->determineYear(20));
Save Holidays for a concrete year
$fetch = app(\ArtARTs36\LaravelHoliday\Services\Fetch::class);

$fetch->fetch('2019');
Save Holidays for a current year
$fetch = app(\ArtARTs36\LaravelHoliday\Services\Fetch::class);

$fetch->fetch(\ArtARTs36\LaravelHoliday\Services\Fetch::TYPE_CURRENT_YEAR);
Save Holidays for a current month
$fetch = app(\ArtARTs36\LaravelHoliday\Services\Fetch::class);

$fetch->fetch(\ArtARTs36\LaravelHoliday\Services\Fetch::TYPE_CURRENT_MONTH);
Save Holidays for a next week
$fetch = app(\ArtARTs36\LaravelHoliday\Services\Fetch::class);

$fetch->fetch(\ArtARTs36\LaravelHoliday\Services\Fetch::TYPE_NEXT_WEEK);