NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Onboarding for Laravel

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:

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:

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

By donating, you agree to our donation terms.

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.