---
title: "DI and actions — Sluggable for Laravel | Roundly"
description: "Inject SlugManager for the facade’s API without static calls, or run the action behind a method directly with its DTO."
url: https://roundly-consulting.com/open-source/docs/sluggable-for-laravel/without-facade
language: en
---

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

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

# DI and actions

The facade is sugar — there are three equivalent entry points, and the choice is yours:

- The Slugs facade — the shortest, and the recommended default.
- The manager, injected through the constructor — the same API as an explicit dependency, with no static calls. RoundlyConsulting\\Sluggable\\SlugManager is the facade root.
- Actions — single-purpose classes with an execute() method, for composing into your own actions, jobs and commands.

## Injecting the manager

```php
use RoundlyConsulting\Sluggable\Enums\RegenerationMode;
use RoundlyConsulting\Sluggable\SlugManager;

final class BackfillSlugs
{
    public function __construct(private SlugManager $slugs) {}

    public function __invoke(): void
    {
        $this->slugs->model(Product::class)->regenerate(mode: RegenerationMode::Missing);
    }
}
```

## Running an action

Each facade method runs one action, resolved from the container. The actions take a DTO — RegenerateSlugsData for regeneration, as here:

```php
use RoundlyConsulting\Sluggable\Actions\RegenerateSlugsAction;
use RoundlyConsulting\Sluggable\DataTransferObjects\RegenerateSlugsData;
use RoundlyConsulting\Sluggable\Enums\RegenerationMode;

$report = app(RegenerateSlugsAction::class)->execute(
    new RegenerateSlugsData(Product::class, mode: RegenerationMode::Stale),
);   // RegenerationReport
```

| Method | Action |
| --- | --- |
| `apply(), recompute(), regenerate()` | `GenerateSlugsAction` |
| `model()->regenerate()` | `RegenerateSlugsAction` |
| `model()->queueRegeneration()` | `QueueSlugRegenerationAction (dispatches RegenerateSlugsJob)` |
| `model()->duplicates()` | `FindDuplicateSlugsAction` |
| `model()->findInHistory()` | `ResolveSlugFromHistoryAction` |
| `model()->indexes()` | `SlugIndexes::forModel() (schema helper, also usable in migrations)` |

RecordSlugHistoryAction is internal — a step of the save pipeline; history is recorded by saving, not by calling 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/sluggable-for-laravel.md)
