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 providerOnboard::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.
0 comments:
Post a Comment
Thanks