Installation
Require the package, then publish and run the migrations — six tables, all prefixed opening_hours_. The service provider is auto-discovered, so there is nothing to register:
composer require roundly-consulting/opening-hours-for-laravel
php artisan vendor:publish --tag="opening-hours-migrations"
php artisan migrateThe config file and the translations (en, sk) are optional — publish them only to override defaults or wording:
php artisan vendor:publish --tag="opening-hours-config"
php artisan vendor:publish --tag="opening-hours-translations"Publish tags
| Tag | Publishes |
|---|---|
opening-hours-migrations | Six timestamped migrations — publish-only; nothing is auto-loaded. |
opening-hours-config | config/opening-hours.php |
opening-hours-translations | lang/vendor/opening-hours/{en,sk} |
UUID and ULID owners
If the models that own opening hours use UUID or ULID keys, set OPENING_HOURS_KEY_TYPE before running the migrations — it decides the owner_id column type in opening_hours_calendars and opening_hours_intervals. Matching ignores case and padding; any other value throws the toolkit’s InvalidConfigurationException when the migrations run:
# bigint (default), uuid or ulid — set before running the migrations
OPENING_HOURS_KEY_TYPE=uuidRecommended scheduling
Two maintenance commands are meant to run daily — pruning (once prune.* is configured) and interval materialization (only with materialize.enabled):
// routes/console.php
use Illuminate\Support\Facades\Schedule;
Schedule::command('opening-hours:prune')->daily(); // with prune.* configured
Schedule::command('opening-hours:materialize')->daily(); // only with materialize.enabledShow your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.