All packages
Onboarding for Laravel
Serializing for an API
Flow::toArray() produces a structure ready to hand to a frontend:
[
'title' => 'Profile Onboarding',
'percentage' => 50.0,
'next_step' => [
'key' => 'upload-photo',
'title' => 'Upload Photo',
'cta' => 'Upload Now',
'action' => 'users@photo@upload',
'is_completed' => false,
'is_optional' => false,
'meta' => [],
'group' => null,
],
'current_step' => [
// same shape as next_step
],
'is_completed' => false,
'steps' => [
// each step as ['key', 'title', 'cta', 'action', 'is_completed', 'is_optional', 'meta', 'group']
],
]next_step and current_step carry the same step; both are null once no visible step is left incomplete. Titles and CTAs are the resolved copy.
Typed DTOs
For a typed equivalent, Flow::toData() returns a FlowData DTO and Step::toData() a StepData. Every DTO is final readonly and implements Arrayable and JsonSerializable:
use RoundlyConsulting\Onboarding\DataTransferObjects\FlowData;
$data = Onboarding::for($user)?->toData(); // ?FlowData
$data?->title; // ?string
$data?->percentage; // float
$data?->currentStep; // ?StepData — the same step as $data->nextStep
$data?->steps; // list<StepData>
$data?->isCompleted; // bool
$data?->currentStep?->key; // 'upload-photo'
$data?->currentStep?->title; // resolved title| DTO | Properties | Source |
|---|---|---|
FlowData | title, percentage, nextStep, currentStep, steps, isCompleted | Returned by Flow::toData(). |
StepData | key, title, cta, action, isCompleted, isOptional, meta, group | Returned by Step::toData(); title and cta are resolved. |
SectionData | key, title, percentage, isCompleted, steps | Returned by sections(), groups() and section(). |
In an API route
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use RoundlyConsulting\Onboarding\Facades\Onboarding;
Route::middleware('auth')->get('/api/onboarding', function (Request $request) {
return response()->json(Onboarding::for($request->user())?->toData());
});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 cryptoBy 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.