A Laravel package to help track user onboarding steps.

Related tags

Laravel onboard
Overview

Onboard

A Laravel package to help track user onboarding steps.

Installation:

  • Install the package via composer
composer require calebporzio/onboard
  • Register the Service Provider and Facade in config/app.php
'providers' => [
    ...
    Calebporzio\Onboard\OnboardServiceProvider::class,

'aliases' => [
    ...
    Calebporzio\Onboard\OnboardFacade::class,
  • Add the Calebporzio\Onboard\GetsOnboarded trait to your app's User model
class User extends Model
{
    use \Calebporzio\Onboard\GetsOnboarded;
    ...

Example Configuration:

Configure your steps in your App\Providers\AppServiceProvider.php

use App\User;
use Calebporzio\Onboard\OnboardFacade;

class AppServiceProvider extends ServiceProvider
{
    // ...

    public function boot()
    {
	    OnboardFacade::addStep('Complete Profile')
	    	->link('/profile')
	    	->cta('Complete')
	    	->completeIf(function (User $user) {
	    		return $user->profile->isComplete();
	    	});

	    OnboardFacade::addStep('Create Your First Post')
	    	->link('/post/create')
	    	->cta('Create Post')
	    	->completeIf(function (User $user) {
	    		return $user->posts->count() > 0;
	    	});

Usage:

Now you can access these steps along with their state wherever you like. Here is an example blade template:

@if (auth()->user()->onboarding()->inProgress())
	<div>

		@foreach (auth()->user()->onboarding()->steps as $step)
			<span>
				@if($step->complete())
					<i class="fa fa-check-square-o fa-fw"></i>
					<s>{{ $loop->iteration }}. {{ $step->title }}</s>
				@else
					<i class="fa fa-square-o fa-fw"></i>
					{{ $loop->iteration }}. {{ $step->title }}
				@endif
			</span>
						
			<a href="{{ $step->link }}" {{ $step->complete() ? 'disabled' : '' }}>
				{{ $step->cta }}
			</a>
		@endforeach

	</div>
@endif

Check out all the available features below:

$onboarding = Auth::user()->onboarding();

$onboarding->inProgress();

$onboarding->finished();

$onboarding->steps()->each(function($step) {
	$step->title;
	$step->cta;
	$step->link;
	$step->complete();
	$step->incomplete();
});

Definining custom attributes and accessing them:

// Defining the attributes
OnboardFacade::addStep('Step w/ custom attributes')
	->attributes([
		'name' => 'Waldo',
		'shirt_color' => 'Red & White',
	]);

// Accessing them
$step->name;
$step->shirt_color;

Example middleware

If 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:

<?php

namespace App\Http\Middleware;

use Auth;
use Closure;

class RedirectToUnfinishedOnboardingStep
{
    public function handle($request, Closure $next)
    {
        if (auth()->user()->onboarding()->inProgress()) {
            return redirect()->to(
                auth()->user()->onboarding()->nextUnfinishedStep()->link
            );
        }
        
        return $next($request);
    }
}

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.

Comments
  • Unresolvable dependency resolving [Parameter #0 [ <required> $user ]] in class Calebporzio\Onboard\OnboardingManager

    Unresolvable dependency resolving [Parameter #0 [ $user ]] in class Calebporzio\Onboard\OnboardingManager

    Hi,

    I'm getting an unresolvable dependencing resolving as somehow it's not passing on the $user class properly. I'm using spark and this is my User model:

    <?php
    
    namespace App;
    
    use Laravel\Spark\CanJoinTeams;
    use Laravel\Passport\HasApiTokens;
    use Laravel\Spark\User as SparkUser;
    use Calebporzio\Onboard\GetsOnboarded;
    
    class User extends SparkUser
    {
        use CanJoinTeams, HasApiTokens, GetsOnboarded;
    
    opened by factormaarten 12
  • Laravel 5.8 support

    Laravel 5.8 support

    Are there any plans to support Laravel 5.8? I'm wondering if it requires anything besides adding it to the composer.json file or if the package actually needs to be updated?

    opened by petersuhm 5
  • Possible to have an end-to-end working example that uses  calebporzio/onboard?

    Possible to have an end-to-end working example that uses calebporzio/onboard?

    @calebporzio thank you for this package and the work you're doing for Laravel. I've been looking for a good package to add an onboarding flow to my app, and this is the only one out there.

    Would it be possible for you to put out an end-to-end (simple) working example? It would help me and others that are stuck with the instructions.

    opened by connecteev 4
  • How to reduce queries?

    How to reduce queries?

    Implemented per instructions, and it works great, however I'm getting a huge jump in the number of queries - specifically the number of duplicated queries.

    For example, on my dashboard I had 7 queries, 2 duplicated. After adding 8 Onboarding steps I have 28queries, 23 duplicated.

    Any idea why the high number of duplicate queries?

    opened by kiogo 3
  • Support Laravel 5.7.*

    Support Laravel 5.7.*

    As the title suggests, the installation fails for laravel 5.7.*. Migration of 5.6 to 5.7 has only a few changes required. It may not even require any change for this package though I am not sure.

    opened by usamaejaz 2
  • Unable to redirect back to a step, getting ERR_TOO_MANY_REDIRECTS

    Unable to redirect back to a step, getting ERR_TOO_MANY_REDIRECTS

    My setup looks like following.

    AppServiceProvider.php

    OnboardFacade::addStep('Connect Slack App')
        ->link('/connect-slack')
        ->cta('Complete')
        ->completeIf(function (User $user) {
            return $user->hasTaskCreator('slack');
        });
    

    Added middleware in my krenel.php under web

    ...
    \App\Http\Middleware\RedirectToUnfinishedOnboardingStep::class,
    ...
    

    When logged in I am redirected to proper link /connect-slack.

    But it's a 404 because there is no route as /connect-slack. When I add a route in my web.php and try to visit the page I get too many redirects.

    This is how I connect view to the route.

    Route::get('/connect-slack', function () {
        return view('onboarding.slack-connect');
    })->name('connect-slack');
    

    How can I add the view to the route?

    opened by bhanu-krenovate 1
  • Bump league/flysystem from 1.0.32 to 1.1.4

    Bump league/flysystem from 1.0.32 to 1.1.4

    Bumps league/flysystem from 1.0.32 to 1.1.4.

    Release notes

    Sourced from league/flysystem's releases.

    1.0.62

    When resources are not actually file pointers, but fopen results from URL, the fstat call fails. This resulted in an error in PHP 7.4 because it's more strict about variable handling. This affected the Util::getStreamSize utility method.

    Commits
    • f3ad691 Reject paths with funky whitespace.
    • 1ac14e9 Added SharePoint community adapter
    • 4347fe7 Remove ext-fileinfo from suggests, it's already in requires
    • 1bf07fc Fix time-related tests failing in 2021
    • 13352d2 Remove @​deprecated MountManager
    • 2062a94 Adding AsyncAWS under community support
    • 53f16fd More precise signatures
    • 2323c98 Add missing emptyDir annotation
    • 9be3b16 Pre-release changelog
    • f66f0e5 Prevent passing invalid resources.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Feature Request: Onboarding Percentage and Current Step

    Feature Request: Onboarding Percentage and Current Step

    Hi there, I need to show Onboarding Percentage and Current Step to the user, any work done on that front, maybe on a Fork or Branch I could look at? Thanks

    opened by full-stack-dev-mex 1
  • Use `Arr::get` instead of the deprecated `array_get`

    Use `Arr::get` instead of the deprecated `array_get`

    In Laravel 6 the array_* helpers has been removed from the core framework (https://laravel.com/docs/6.x/upgrade#helpers) So changed it to use the Illuminate\Support\Arr class instead, and that is also the same in previous versions.

    https://github.com/calebporzio/onboard/issues/22

    opened by martindilling 1
  • Edited README as it is working for me

    Edited README as it is working for me

    Old version of readme didn't work for me, threw same error as #15 bug. Also changed Auth::user() to auth()->user() everywhere, this way you don't need to add use ...Auth in every file.

    opened by PovilasKorop 1
  • Class 'App\Providers\Onboard' not found

    Class 'App\Providers\Onboard' not found

    Got Fatal Error when adding

    	    Onboard::addStep('Complete Profile')
    	    	->link('/profile')
    	    	->cta('Complete')
    	    	->completeIf(function (User $user) {
    	    		return $user->profile->isComplete();
    	    	});
    

    in App\Providers\AppServiceProvider.php

    opened by fsuuaas 1
Releases(v1.7)
Owner
Caleb Porzio
worker on the web
Caleb Porzio
Thunder is an advanced Laravel tool to track user consumption using Cashier's Metered Billing for Stripe. ⚡

⚡ Thunder Thunder is an advanced Laravel tool to track user consumption using Cashier's Metered Billing for Stripe. ⚡ ?? Supporting If you are using o

Renoki Co. 10 Nov 21, 2022
Laravel Seeable - Keep track of the date and time a user was last seen.

Laravel Seeable This package makes it easy to keep track of the date and time a user was last seen. Installation Install this package. composer requir

Zep Fietje 29 Dec 26, 2022
laravel package help you to implement geographical calculation, with several algorithms that help you deal with coordinates and distances.

Geographical Calculator Geographical Calculator was developed for laravel 5.8+ to help you to implement geographical calculation, with With several al

karam mustafa 342 Dec 31, 2022
This package allows you to easily track your laravel jobs!

Trackable Jobs For Laravel This package allows you to track your laravel jobs! Using this package, you can easily persist the output and the status of

Mateus Junges 220 Dec 25, 2022
A package to keep track of outgoing emails in your Laravel application.

Keep track of outgoing emails and associate sent emails with Eloquent models This package helps you to keep track of outgoing emails in your Laravel a

Stefan Zweifel 108 Nov 1, 2022
A package to keep track of your pages & understand your audience

A clean way to track your pages & understand your user's behavior Installation You can install the package via composer: composer require coderflexx/l

Coderflex 178 Jan 4, 2023
Laravel plugin to track your users logins and alert when a suspicious login occurs

Laravel Suspicious Logins Detect suspicious logins for standard Laravel authentication (base Laravel, Jetstream, etc) and notify a list of administrat

Advent Development 74 May 1, 2022
🕵🏻‍♂️  The easiest way to respect the "do not track" header in Laravel

trackable The easiest way to respect the "do not track" header in Laravel Installation composer require s360digital/trackable API Trackable will expos

s360 2 Oct 7, 2022
Testbench Component is the de-facto package that has been designed to help you write tests for your Laravel package

Laravel Testing Helper for Packages Development Testbench Component is the de-facto package that has been designed to help you write tests for your La

Orchestra Platform 1.9k Dec 29, 2022
User authentication REST API with Laravel (Register, Email verification, Login, Logout, Logged user data, Change password, Reset password)

User Authentication API with Laravel This project is a user authentication REST API application that I developed by using Laravel and MySql. Setup Fir

Yusuf Ziya YILDIRIM 3 Aug 23, 2022
GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn

GeoLocation in PHP (API) ?? ?? ?? This package helps you to know a lot of information about the current user by his ip address ?? ?? ?? This package h

Abdullah Karam 4 Dec 8, 2022
PHP package to help the development of Laravel-based Telegram bots

Laravel-telegram-bot Project description goes here. This description is usually two to three lines long. It should give an overview of what the projec

CC - UFFS 6 May 10, 2021
this package can help you to test race condition in Laravel Feature Test

Laravel Async Testing this package can help you to test race condition in Laravel Feature Test Requirements Laravel versions 5.7, 6.x, 7.x and 8.x PHP

Recca Tsai 61 Nov 5, 2022
Laravel Livewire package for clone screen with the help of websocket

screen-wire This is a Laravel Livewire package. It allow you to see what users are doing on their screen. Installation composer require mrbohem/scree

Shivam Upadhyay 2 Aug 29, 2022
a Laravel package help you to execute more effective databases queries.

Laravel Query Helper Laravel Query Helper was developed for laravel 7.2+ to help you optimizing sql queries, this package will contain all advanced sq

karam mustafa 9 Jul 26, 2022
This package should help you with creating and managing a Laravel DDD Application

This package should help you with creating and managing a Laravel DDD Application. This package is heavily inspired by "Laravel beyond CRUD" from Spatie.

J. Regner 158 Dec 25, 2022
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

null 9 Dec 14, 2022
Relational Metrics - lararvel package help you to make your metrics easier

Relational Metrics This package will help you to make your metrics easier, You could get metrics about your Models, Models depending on their relation

Syrian Open Source 25 Oct 12, 2022
This package aims to help you standardize all your API responses in a simple and structured way.

Laravel API Response This package aims to help you standardize all your API responses in a simple and structured way. By default, the stucture of the

Kode Pandai 6 Dec 6, 2022