artarts36 / laravel-holiday
Your Package Description here
1.0.4
2021-04-28 21:50 UTC
Requires
- php: >=7.2.0
- ext-json: *
- doctrine/dbal: ^2.6
- guzzlehttp/guzzle: >=6.0
- laravel/framework: 6.*
Requires (Dev)
- fzaninotto/faker: ^1.9
- mockery/mockery: ^1.0
- orchestra/testbench: 4.*
- phpunit/phpunit: 7.* | 8.*
- squizlabs/php_codesniffer: 3.*
- symfony/thanks: ^1.0
README
With this package you can save dates of holidays or shortened days on your Laravel application.
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
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);