---
title: "Extending — Opening Hours for Laravel | Roundly"
description: "Swap in your own model subclasses, hook the owner’s timezone and dynamic exceptions, and plug in custom providers."
url: https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel/extending
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Opening Hours for Laravel](https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel.md)

# Extending

## Swapping models

Point models.calendar, models.schedule or models.exception\_rule at a subclass of the packaged model — they are deliberately non-final. Set the keys in config rather than at runtime; a class that is not the packaged model or a subclass of it throws the toolkit’s InvalidConfigurationException naming the key — it is never silently replaced:

```php
// app/Models/Calendar.php
namespace App\Models;

final class Calendar extends \RoundlyConsulting\OpeningHours\Models\Calendar
{
    protected $connection = 'tenant';
}

// config/opening-hours.php
'models' => [
    'calendar' => App\Models\Calendar::class,
    'schedule' => RoundlyConsulting\OpeningHours\Models\Schedule::class,
    'exception_rule' => RoundlyConsulting\OpeningHours\Models\ExceptionRule::class,
],
```

Transactions use the calendar model’s own connection, so a swapped model on another connection works.

## Owner hooks

- openingHoursTimezone(): ?string — the timezone for calendars without their own.
- openingHoursDynamicExceptions(): array — DynamicExceptionProvider instances applied to the owner’s calendars.

## Custom providers

Implement DynamicExceptionProvider for computed holidays (see Exceptions and holidays) and BusyPeriodProvider for any source of occupied time (see Busy-period providers). Neither needs registration — pass them to the owner hook, withDynamicExceptions() or withBusyPeriods().

## 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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

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

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel.md)
