---
title: "DI and actions — Addresses for Laravel | Roundly"
description: "Skip the facade: inject AddressManager or run one of the four actions directly — the facade method → action map."
url: https://roundly-consulting.com/open-source/docs/addresses-for-laravel/without-facade
language: en
---

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

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

# DI and actions

The facade is the recommended default, not the only way in. Three entry points run the same code: the Addresses facade (shortest), the manager RoundlyConsulting\\Addresses\\AddressManager — the facade root, an autowired container singleton — injected through the constructor (same API, explicit dependency, no static calls), and actions (single-purpose classes with execute(), for composing into your own actions, jobs and commands).

## Inject the manager

```php
use App\Models\User;
use RoundlyConsulting\Addresses\Actions\CreateAddressAction;
use RoundlyConsulting\Addresses\Address;
use RoundlyConsulting\Addresses\AddressManager;
use RoundlyConsulting\Addresses\DataTransferObjects\AddressData;

final class SaveBillingAddress
{
    public function __construct(private AddressManager $addresses) {}

    public function __invoke(User $user, AddressData $data): Address
    {
        return $this->addresses->for($user)->add($data);
    }
}

app(CreateAddressAction::class)->execute($user, $data);   // the raw action
```

## Facade method → action

| Facade call | Action |
| --- | --- |
| `Addresses::for($o)->add($data) / ->new()->…->save()` | `CreateAddressAction::execute($o, $data)` |
| `Addresses::for($o)->setPrimary($address)` | `SetPrimaryAddressAction::execute($o, $address)` |
| `Addresses::update($address, $data)` | `UpdateAddressAction::execute($address, $data)` |
| `Addresses::delete($address)` | `DeleteAddressAction::execute($address)` |

- Every owner-scoped call — from the facade, an address book, the builder or a HasAddresses shortcut — goes through the manager, so host overrides and Addresses::fake() see it.
- Addresses::fake() swaps the manager in the container too, so injected managers are faked as well. An action you call directly bypasses the fake and runs for real.
- The actions resolve from the container and take any Eloquent model as the owner — the HasAddresses trait is not required.
- PromoteAddressAction is internal — the primary invariant behind add, update and setPrimary. Promote an address with Addresses::for($owner)->setPrimary($address).

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