NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Opening Hours for Laravel

Caching and eager loading

Compiled definitions are cached per (calendar, revision). Every write bumps the revision inside its transaction, so there is nothing to invalidate — old keys simply expire by cache.ttl. The cache stores plain arrays, uses no tags and works with any store.

List pages without N+1

Clinic::query()->withOpeningHours()->paginate();                  // headers only (cache on)
Clinic::query()->withOpeningHours(definitions: true)->paginate(); // full definitions (cache off)

With the cache on, headers are enough — the revision lives on the header. Hosts without a cache load full definitions with definitions: true.

Staying fresh

Direct Eloquent edits of schedules, exceptions and ranges bump the revision automatically. After raw SQL edits, or when what openingHoursTimezone() returns changes, call refresh():

use RoundlyConsulting\OpeningHours\Facades\OpeningHours;

OpeningHours::refresh($clinic);            // after raw SQL or a changed openingHoursTimezone()
OpeningHours::refresh($clinic, 'pickup');  // a named calendar
OpeningHours::flushMemo();                 // clear the per-request memo

The manager behind the facade is bound scoped, so its memo of compiled definitions lives for one request or job — safe under Octane and queues. The owner’s timezone hook and dynamic providers are resolved per call, never cached. A corrupt cache payload is treated as a miss and recompiled.

Show 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 crypto

By 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.