Laravel Packages

A Package for Onboarding Users in Laravel Apps

Published
A Package for Onboarding Users in Laravel Apps image

Laravel Onboard is a Laravel package to help track user onboarding steps created by Spatie:

Here's a quick example taken from the project readme on using this package to create onboarding steps:

use App\User;
use Spatie\Onboard\Facades\Onboard;
 
// You can add onboarding steps in a `boot()` method within a service provider
Onboard::addStep('Complete Profile')
->link('/profile')
->cta('Complete')
->completeIf(function (User $user) {
return $user->profile->isComplete();
});
 
Onboard::addStep('Create Your First Post')
->link('/post/create')
->cta('Create Post')
->completeIf(function (User $user) {
return $user->posts->count() > 0;
});

To get a user's onboarding status—among other things—the package has a nice API for accessing things like percentage complete, in progress, finished, and details about individual steps:

/** @var \Spatie\Onboard\OnboardingManager $onboarding **/
$onboarding = Auth::user()->onboarding();
 
$onboarding->inProgress();
 
$onboarding->percentageCompleted();
 
$onboarding->finished();
 
$onboarding->steps()->each(function($step) {
$step->title;
$step->cta;
$step->link;
$step->complete();
$step->incomplete();
});

Additionally, this package supports features such as:

  • Conditionally excluding steps with custom logic
  • Defining custom attributes on a step
  • Use middleware to ensure a user completes onboarding before they are allowed to use certain features
  • And more

You can get started with this package by checking it out on GitHub at spatie/laravel-onboard. Their blog post can also give you some examples and further details on how you can use this package.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article