PHP code example of reinbier / laravel-holiday

1. Go to this page and download the library: Download reinbier/laravel-holiday library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

reinbier / laravel-holiday example snippets


return [

    /**
     * The name of the table to use. You can adjust this to suit your needs.
     */
    'table_name' => 'holidays',

    /**
     * If you want to use a different locale to generate holidays for,
     * you can set it here. For now, a sensible default is set.
     */
    'locale' => config('app.locale', 'nl'),

    /**
     * When true, sets the holidays for Carbon in the service container.
     */
    'enable_carbon' => false,
    
];


    protected function schedule(Schedule $schedule)
    {
        // ...
        
        $schedule->command('holiday:generate')->yearly();
    }

use Reinbier\LaravelHoliday\Facades\LaravelHoliday;

// The Holiday model of the current year
$holiday = LaravelHoliday::model();

// All holiday-dates in a Collection
$holidays = LaravelHoliday::getHolidays(); 

// Set the Holiday model and chain methods
LaravelHoliday::forYear(2023)
    ->addHoliday('2023-06-07', 'boss-birthday')
    ->getHolidays();

// Simply add multiple holidays by chaining
LaravelHoliday::forYear(2023)
    ->addHoliday('2023-06-07', 'boss-birthday')
    ->addHoliday('2023-10-10', 'anniversary')
    -> ...

use Reinbier\LaravelHoliday\Facades\LaravelHoliday;

$future_holidays = LaravelHoliday::getFutureHolidays();
// You may optionally specify a year, until when to retrieve holidays 
$future_holidays = LaravelHoliday::getFutureHolidays(2035); 

'enable_carbon' => true,
bash
php artisan vendor:publish --tag="holiday-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="holiday-config"
bash
php artisan holiday:generate