---
title: "DI and actions — Notifications for Laravel | Roundly"
description: "Skip the facade: inject NotificationsManager or call a single-purpose action — every host-facing action with its execute() signature and facade path."
url: https://roundly-consulting.com/open-source/docs/notifications-for-laravel/without-facade
language: en
---

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

[Notifications for Laravel](https://roundly-consulting.com/open-source/docs/notifications-for-laravel.md)

# DI and actions

The facade is the recommended default, not the only way in. Every operation is an action, the manager exposes each one and the facade is sugar over the manager — all three run the same code. The manager is RoundlyConsulting\\Notifications\\NotificationsManager, the facade’s root, bound as a container singleton:

```php
use RoundlyConsulting\Notifications\Actions\Sending\SendNotificationAction;
use RoundlyConsulting\Notifications\DataTransferObjects\SendNotificationData;
use RoundlyConsulting\Notifications\Facades\Notifications;
use RoundlyConsulting\Notifications\NotificationsManager;
use RoundlyConsulting\Notifications\Recipients;

// 1. Facade
Notifications::send('request.awaiting_approval', $request, $approvers, ['reference' => $request->reference]);

// 2. Dependency injection — the same API, no facade
app(NotificationsManager::class)->send('request.awaiting_approval', $request, $approvers);

// 3. The raw action
app(SendNotificationAction::class)->execute(new SendNotificationData(
    type: 'request.awaiting_approval',
    subject: $request,
    recipients: Recipients::users(...$approvers),
));
```

## Inject the manager

```php
use Illuminate\Http\RedirectResponse;
use RoundlyConsulting\Notifications\NotificationsManager;
use RoundlyConsulting\Notifications\Recipients;

final class SubmitPurchaseRequestController
{
    public function __construct(private NotificationsManager $notifications) {}

    public function __invoke(PurchaseRequest $request): RedirectResponse
    {
        $request->submit();

        $this->notifications->type('request.awaiting_approval')
            ->about($request)
            ->to(Recipients::role($request->company, 'approver'))
            ->by($request->author)
            ->once("request-submitted:{$request->id}")
            ->send();

        return to_route('requests.show', $request);
    }
}
```

The manager is not final on purpose: the fake extends it, so code that injects NotificationsManager still type-checks under Notifications::fake().

## Call an action

```php
use RoundlyConsulting\Notifications\Actions\Inbox\MarkInboxItemReadAction;
use RoundlyConsulting\Notifications\Actions\Preferences\UpdatePreferencesAction;
use RoundlyConsulting\Notifications\Actions\Reminders\AcknowledgeAction;

// Notifications::inbox($user)->markRead($item)  ≡
app(MarkInboxItemReadAction::class)->execute($user, $item);

// Notifications::preferences($user)->update($update)  ≡
app(UpdatePreferencesAction::class)->execute($user, $update);

// Notifications::for($contract)->acknowledge('contract.expiring', by: $user)  ≡
app(AcknowledgeAction::class)->execute($contract, 'contract.expiring', $user);
```

## Facade method → action

Namespaces are relative to RoundlyConsulting\\Notifications\\Actions:

| Action | execute(…) | Returns | Facade path |
| --- | --- | --- | --- |
| `Sending\SendNotificationAction` | `execute(SendNotificationData)` | `SendResult` | send() · sendNotification() · type()->send() · for()->send() |
| `Inbox\MarkInboxItemReadAction` | `execute($recipient, $item)` | `InboxItem` | inbox()->markRead() |
| `Inbox\MarkInboxItemUnreadAction` | `execute($recipient, $item)` | `InboxItem` | inbox()->markUnread() |
| `Inbox\MarkAllInboxItemsReadAction` | `execute($recipient, $in, $category, $type, $withoutContext, $since)` | `int` | inbox()->markAllRead() |
| `Inbox\ArchiveInboxItemAction · UnarchiveInboxItemAction` | `execute($recipient, $item)` | `InboxItem` | inbox()->archive() · unarchive() |
| `Inbox\DeleteInboxItemAction` | `execute($recipient, $item)` | `void` | inbox()->delete() |
| `Inbox\RevokeNotificationsAction` | `execute($subject, ?$recipient)` | `int` | for()->revoke() |
| `Inbox\RecordInboxMessageAction` | `execute($recipient, InboxMessage)` | `?InboxItem` | inboxMessage() · the inbox channel |
| `Preferences\SetChannelPreferenceAction` | `execute($user, $type, list<Channel>, ?bool)` | `void` | preferences()->mute() · unmute() · set() |
| `Preferences\SetCategoryPreferenceAction` | `execute($user, $category, list<Channel>, ?bool)` | `void` | preferences()->muteCategory() · unmuteCategory() |
| `Preferences\ResetPreferencesAction` | `execute($user)` | `void` | preferences()->reset() |
| `Preferences\SetDigestPreferenceAction` | `execute($user, DigestPreferenceData)` | `void` | preferences()->digest() |
| `Preferences\SetQuietHoursAction` | `execute($user, ?QuietHours)` | `void` | preferences()->quietHours() |
| `Preferences\SetNotificationTimezoneAction` | `execute($user, ?string)` | `void` | preferences()->timezone() |
| `Preferences\UpdatePreferencesAction` | `execute($user, PreferencesUpdate)` | `void` | preferences()->update() · PATCH /preferences |
| `Delivery\DispatchDueDeliveriesAction` | `execute()` | `int` | deliveries()->dispatchDue() |
| `Digests\SendDueDigestsAction · PreviewDigestAction` | `execute() · execute($user)` | `int · ?MailMessage` | digests()->sendDue() · preview() |
| `Reminders\SyncRemindersAction` | `execute($subject, ?$type)` | `int` | for()->reminders()->sync() |
| `Reminders\ScheduleRemindersAction` | `execute($subject, $type, RecipientSpec)` | `list<NotificationReminder>` | for()->reminders()->schedule() |
| `Reminders\RemindAction` | `execute($subject, $type, ReminderRule, RecipientSpec, $data)` | `list<NotificationReminder>` | for()->remind() |
| `Reminders\CancelRemindersAction` | `execute($subject, ?$type, CancelReason)` | `int` | for()->reminders()->cancel() |
| `Reminders\AcknowledgeAction` | `execute($subject, ?$type, ?$by)` | `int` | for()->acknowledge() · reminders()->acknowledge() |
| `Reminders\FireDueRemindersAction · BackfillRemindersAction` | `execute() · execute($type)` | `FiredReminders · int` | reminders()->fireDue() · backfill() |
| `Maintenance\SweepAction · PruneNotificationsAction` | `execute(?$only) · execute()` | `SweepReport · PruneReport` | sweep() · prune() |

- Every mutating call — from the facade, an injected manager, a handle, the fluent builder, a model trait or the inbox channel — funnels through the manager, which resolves the action from the container, so a container binding of an action applies everywhere.
- Notifications::fake() swaps the manager in the container too, so an injected NotificationsManager is faked as well. Calling an action directly is not recorded.
- Internal building blocks — ResolveRecipientsAction, DeliverToRecipientAction, RecordInboxItemAction, QueueMailDeliveryAction, RecomputeDeferredDeliveriesAction, DeliverMailAction, ExpireStaleClaimsAction, SendDigestAction, FireReminderAction, FireEscalationAction, ApplyInteropRulesAction and ReleaseHeldInteropMailAction — are not for app code.

## 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/notifications-for-laravel.md)
