{"id":19324849,"url":"https://github.com/spatie/laravel-onboard","last_synced_at":"2025-05-14T05:10:23.489Z","repository":{"id":36959215,"uuid":"504284316","full_name":"spatie/laravel-onboard","owner":"spatie","description":"A Laravel package to help track user onboarding steps","archived":false,"fork":false,"pushed_at":"2025-05-12T01:48:23.000Z","size":99,"stargazers_count":708,"open_issues_count":1,"forks_count":28,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-12T02:40:53.305Z","etag":null,"topics":["laravel","onboarding","php","saas"],"latest_commit_sha":null,"homepage":"https://rias.be/blog/laravel-package-to-onboard-your-users","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-16T19:39:27.000Z","updated_at":"2025-05-12T01:48:21.000Z","dependencies_parsed_at":"2024-11-17T03:00:53.934Z","dependency_job_id":"77b68c65-e812-4afe-bfdb-38947eacb474","html_url":"https://github.com/spatie/laravel-onboard","commit_stats":{"total_commits":58,"total_committers":16,"mean_commits":3.625,"dds":0.6724137931034483,"last_synced_commit":"ee6e31d6d9ce4020f9bcb31635b26bc2deed6719"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-onboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-onboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-onboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-onboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-onboard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253665646,"owners_count":21944615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","onboarding","php","saas"],"created_at":"2024-11-10T02:07:08.488Z","updated_at":"2025-05-14T05:10:23.456Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Laravel package to help track user onboarding steps\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-onboard.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-onboard)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-onboard.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-onboard)\n\nThis package lets you set up an onboarding flow for your application's users.\n\nHere's an example of how it's set up:\n\n```php\nuse App\\User;\nuse Spatie\\Onboard\\Facades\\Onboard;\n\nOnboard::addStep('Complete Profile')\n    -\u003elink('/profile')\n    -\u003ecta('Complete')\n    -\u003ecompleteIf(function (User $model) {\n        return $model-\u003eprofile-\u003eisComplete();\n    });\n\nOnboard::addStep('Create Your First Post')\n    -\u003elink('/post/create')\n    -\u003ecta('Create Post')\n    -\u003ecompleteIf(function (User $model) {\n        return $model-\u003eposts-\u003ecount() \u003e 0;\n    });\n```\n\nYou can then render this onboarding flow however you want in your templates:\n\n```blade\n@if (auth()-\u003euser()-\u003eonboarding()-\u003einProgress())\n    \u003cdiv\u003e\n        @foreach (auth()-\u003euser()-\u003eonboarding()-\u003esteps as $step)\n            \u003cspan\u003e\n                @if($step-\u003ecomplete())\n                    \u003ci class=\"fa fa-check-square-o fa-fw\"\u003e\u003c/i\u003e\n                    \u003cs\u003e{{ $loop-\u003eiteration }}. {{ $step-\u003etitle }}\u003c/s\u003e\n                @else\n                    \u003ci class=\"fa fa-square-o fa-fw\"\u003e\u003c/i\u003e\n                    {{ $loop-\u003eiteration }}. {{ $step-\u003etitle }}\n                @endif\n            \u003c/span\u003e\n\n            \u003ca href=\"{{ $step-\u003elink }}\" {{ $step-\u003ecomplete() ? 'disabled' : '' }}\u003e\n                {{ $step-\u003ecta }}\n            \u003c/a\u003e\n        @endforeach\n    \u003c/div\u003e\n@endif\n```\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-onboard.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-onboard)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/laravel-onboard\n```\n\n## Usage\n\nAdd the `Spatie\\Onboard\\Concerns\\GetsOnboarded` trait and `Spatie\\Onboard\\Concerns\\Onboardable` interface to any model or class in your app, for example the `User` model:\n\n```php\nclass User extends Model implements \\Spatie\\Onboard\\Concerns\\Onboardable\n{\n    use \\Spatie\\Onboard\\Concerns\\GetsOnboarded;\n    ...\n```\n\n### Example configuration\n\nConfigure your steps in your `App\\Providers\\AppServiceProvider.php`\n\n```php\nuse App\\User;\nuse Spatie\\Onboard\\Facades\\Onboard;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    // ...\n\n    public function boot()\n    {\n        Onboard::addStep('Complete Profile')\n            -\u003elink('/profile')\n            -\u003ecta('Complete')\n            /**\n             * The completeIf will pass the class that you've added the\n             * interface \u0026 trait to. You can use Laravel's dependency\n             * injection here to inject anything else as well.\n             */\n            -\u003ecompleteIf(function (User $model) {\n                return $model-\u003eprofile-\u003eisComplete();\n            });\n\n        Onboard::addStep('Create Your First Post')\n            -\u003elink('/post/create')\n            -\u003ecta('Create Post')\n            -\u003ecompleteIf(function (User $model) {\n                return $model-\u003eposts-\u003ecount() \u003e 0;\n            });\n```\n\nThe variable name passed to the `completeIf` callback must be `$model`.\n\n### Usage\n\nNow you can access these steps along with their state wherever you like. Here is an example blade template:\n\n```blade\n@if (auth()-\u003euser()-\u003eonboarding()-\u003einProgress())\n    \u003cdiv\u003e\n        @foreach (auth()-\u003euser()-\u003eonboarding()-\u003esteps as $step)\n            \u003cspan\u003e\n                @if($step-\u003ecomplete())\n                    \u003ci class=\"fa fa-check-square-o fa-fw\"\u003e\u003c/i\u003e\n                    \u003cs\u003e{{ $loop-\u003eiteration }}. {{ $step-\u003etitle }}\u003c/s\u003e\n                @else\n                    \u003ci class=\"fa fa-square-o fa-fw\"\u003e\u003c/i\u003e\n                    {{ $loop-\u003eiteration }}. {{ $step-\u003etitle }}\n                @endif\n            \u003c/span\u003e\n                        \n            \u003ca href=\"{{ $step-\u003elink }}\" {{ $step-\u003ecomplete() ? 'disabled' : '' }}\u003e\n                {{ $step-\u003ecta }}\n            \u003c/a\u003e\n        @endforeach\n    \u003c/div\u003e\n@endif\n```\n\nCheck out all the available features below:\n\n```php\n/** @var \\Spatie\\Onboard\\OnboardingManager $onboarding **/\n$onboarding = Auth::user()-\u003eonboarding();\n\n$onboarding-\u003einProgress();\n\n$onboarding-\u003epercentageCompleted();\n\n$onboarding-\u003efinished();\n\n$onboarding-\u003esteps()-\u003eeach(function($step) {\n    $step-\u003etitle;\n    $step-\u003ecta;\n    $step-\u003elink;\n    $step-\u003ecomplete();\n    $step-\u003eincomplete();\n});\n```\n\nExcluding steps based on condition:\n\n```php\nOnboard::addStep('Excluded Step')\n    -\u003eexcludeIf(function (User $model) {\n        return $model-\u003eisAdmin();\n    });\n```\n\nLimiting steps to a specific class:\n    \n```php\nOnboard::addStep('Limited Step', User::class)\n    -\u003elink('/post/create');\n\n// or\n\nOnboard::addStep('Limited Step', 'App\\Models\\User')\n    -\u003elink('/post/create');\n```\n\nWhen using limited steps, steps that are not limited will be available to all classes. For example:\n\n```php\n// Defining User steps\nOnboard::addStep('Limited User Step', User::class)\n    -\u003elink('/post/create');\n\n// Defining Team steps\nOnboard::addStep('Limited Team Step', Team::class)\n    -\u003elink('/post/create');\n\n// Defining a step that is available to all classes\nOnboard::addStep('Normal Step')\n    -\u003elink('/post/create');\n```\n\nThe above will result in 1 step being available to all classes, and 2 steps being available to the `User` and `Team` classes:\n\n`Other` classes will only see the `Normal Step`.\n`User` classes will both see the `Normal Step` and `Limited User Step`.\n`Team` classes will both see the `Normal Step` and `Limited Team Step`.\n\n\nDefinining custom attributes and accessing them:\n\n```php\n// Defining the attributes\nOnboard::addStep('Step w/ custom attributes')\n    -\u003eattributes([\n        'name' =\u003e 'Waldo',\n        'shirt_color' =\u003e 'Red \u0026 White',\n    ]);\n\n// Accessing them\n$step-\u003ename;\n$step-\u003eshirt_color;\n```\n\n### Example middleware\n\nIf you want to ensure that your User is redirected to the next unfinished onboarding step, whenever they access your web application, you can use the following middleware as a starting point:\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Middleware;\n\nuse Auth;\nuse Closure;\n\nclass RedirectToUnfinishedOnboardingStep\n{\n    public function handle($request, Closure $next)\n    {\n        if (auth()-\u003euser()-\u003eonboarding()-\u003einProgress()) {\n            return redirect()-\u003eto(\n                auth()-\u003euser()-\u003eonboarding()-\u003enextUnfinishedStep()-\u003elink\n            );\n        }\n        \n        return $next($request);\n    }\n}\n```\n\n**Quick tip:** Don't add this middleware to routes that update the state of the onboarding steps, your users will not be able to progress because they will be redirected back to the onboarding step.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n- [Rias Van der Veken](https://github.com/riasvdv)\n- [All Contributors](../../contributors)\n\nThe original code from this package came from [Onboard](https://github.com/calebporzio/onboard) by [Caleb Porzio](https://github.com/calebporzio), who was gratious enough to let us continue development.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-onboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-onboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-onboard/lists"}