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

To filter owners in SQL — “clinics open now” on a directory page — enable materialization, schedule the command daily and use the scopes:

OPENING_HOURS_MATERIALIZE=true
OPENING_HOURS_MATERIALIZE_DAYS_AHEAD=60
OPENING_HOURS_MATERIALIZE_DAYS_BEHIND=1
// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('opening-hours:materialize')->daily();

// anywhere
Clinic::query()->whereOpenAt(now())->get();
Clinic::query()->whereOpenThroughout($start, $end, 'pickup')->get();
  • The opening_hours_intervals table holds coalesced opening periods as UTC rows for [today − days_behind, today + days_ahead].
  • Every change queues a unique MaterializeIntervalsJob for that calendar on materialize.connection and materialize.queue.
  • Instants outside the materialized horizon throw OutsideMaterializedHorizonException instead of silently answering “closed”.
  • whereOpenAt($at, ?$calendar) and whereOpenThroughout($start, $end, ?$calendar) add an owner-correlated EXISTS; trashed calendars hold no intervals.

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.