---
title: "Choosing the flow per subject — Onboarding for Laravel | Roundly"
description: "Register one resolver that maps each subject to its flow key, with an automatic fallback to the default flow."
url: https://roundly-consulting.com/open-source/docs/onboarding-for-laravel/flow-resolver
language: en
---

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

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

# Choosing the flow per subject

Register a resolver once to map a subject to the flow key it should use, instead of branching by hand:

```php
Onboarding::resolveUsing(fn ($subject) => $subject?->isAdmin() ? 'admin' : 'default');

Onboarding::for($user);                 // the resolved Flow, bound to $user
Onboarding::resolveFor($user);          // the same
Onboarding::resolveFor($user, 'team');  // the same, falling back to "team" instead of "default"
$user->resolvedOnboarding();            // the same as Onboarding::for($user), from the GetsOnboarded trait
```

- The resolver receives the subject — a Model, an Authenticatable or null — and returns a flow key or null.
- Onboarding::for($subject) without a key — and resolveFor() — return a copy of the resolver’s flow, bound to the subject, when that key is registered.
- When the resolver returns null or an unknown key, they fall back to the default flow — or to the key passed as resolveFor()’s second argument; they return null only when neither exists.
- flush() clears the resolver along with the registered flows.

## Resolver versus default key

Every place that reads a subject’s flow without a key asks the resolver first: $user->onboarding(), the model readers (hasCompletedOnboarding(), isOnboarding(), onboardingProgress(), nextOnboardingStep(), dismissOnboardingStep()) and the onboarding middleware. On a model, a null or unknown answer falls back to its defaultOnboardingKey(). An explicit key — $user->onboarding('admin') or onboarding:admin — always wins:

```php
class User extends Model
{
    use GetsOnboarded;

    // the fallback when the resolver answers null or an unknown key
    public function defaultOnboardingKey(): string
    {
        return $this->onboarding_flow ?? 'default';
    }
}
```

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