---
title: "DI and actions — Opening Hours for Laravel | Roundly"
description: "Inject OpeningHoursManager instead of the facade, or call an action directly — the facade-to-action map and what the fake does and doesn’t see."
url: https://roundly-consulting.com/open-source/docs/opening-hours-for-laravel/without-facade
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)

# DI and actions

The facade is the recommended default, not the only way in. Three equivalent entry points run the same code:

- The OpeningHours facade — the shortest form, used throughout these docs.
- The manager, RoundlyConsulting\\OpeningHours\\OpeningHoursManager — the facade root, injected through the constructor. Same API, an explicit dependency and no static calls. It is bound scoped, so one instance (and one memo) serves a request or job.
- Actions — single-purpose classes with execute(), for composing into your own actions, jobs and commands.

## Inject the manager, or call an action

```php
use RoundlyConsulting\OpeningHours\Actions\AddExceptionAction;
use RoundlyConsulting\OpeningHours\DataTransferObjects\ExceptionData;
use RoundlyConsulting\OpeningHours\OpeningHoursManager;

final class CloseForHoliday
{
    public function __construct(private OpeningHoursManager $hours) {}

    public function __invoke(Clinic $clinic, string $date): void
    {
        $this->hours->exceptions($clinic)->closed($date, label: 'Holiday');
    }
}

// The raw action — no relation reset, no fake:
app(AddExceptionAction::class)->execute($clinic->openingHoursCalendar(), ExceptionData::make('2026-12-24'));
```

OpeningHours::fake() swaps the container binding as well as the facade, so a constructor-injected manager and the owner trait are recorded too. An action called directly writes for real — no relation reset, and no fake.

OpeningHoursManager isn’t final: subclass it and rebind the class in the container to change its behaviour. The manager resolves actions per call, so a host rebind of an action is honoured as well.

## Facade method → action

| Facade method | Action |
| --- | --- |
| `sync($owner, $data) · edit()->save() · setOpeningHours()` | `SyncCalendarAction::execute($owner, CalendarData, $key, ?$expectedRevision)` |
| `exceptions($owner)->add() · closed() · open()` | `AddExceptionAction::execute(Calendar, ExceptionData)` |
| `exceptions($owner)->remove($ruleId)` | `RemoveExceptionAction::execute(Calendar, int $ruleId)` |
| `delete($owner, force:)` | `DeleteCalendarAction::execute(Calendar, bool $force)` |
| `refresh($owner)` | `BumpRevisionAction::execute(int $calendarId)` |

Reads — for(), calendar(), has(), exceptions()->all(), validate(), definitionData() — have no action. PruneAction and MaterializeIntervalsAction are @internal: drive them through opening-hours:prune and opening-hours:materialize (or the MaterializeIntervalsJob), not from your code. AddExceptionAction, RemoveExceptionAction and DeleteCalendarAction take the Calendar header — OpeningHours::calendar($owner) returns it.

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