2017 © Pedro Peláez
 

library onboard

Track onboarding steps for users when they get setup in your app.

image

calebporzio/onboard

Track onboarding steps for users when they get setup in your app.

  • Friday, June 22, 2018
  • by calebporzio
  • Repository
  • 3 Watchers
  • 56 Stars
  • 180 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 4 Versions
  • 32 % Grown

The README.md

Note: This package has been archived, you should use it's successor "Laravel Onboard" instead: https://github.com/spatie/laravel-onboard


, (*1)

Onboard

A Laravel package to help track user onboarding steps., (*2)

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, (*3)


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:, (*4)

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


@foreach (auth()->user()->onboarding()->steps as $step) @if($step->complete()) {{ $loop->iteration }}. {{ $step->title }} @else {{ $loop->iteration }}. {{ $step->title }} @endif complete() ? 'disabled' : '' }}> {{ $step->cta }} @endforeach
@endif

Check out all the available features below:, (*5)

$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:, (*6)

// 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:, (*7)

<?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., (*8)

The Versions

22/06 2018

dev-master

9999999-dev

Track onboarding steps for users when they get setup in your app.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Caleb Porzio

22/06 2018

v1.1.1

1.1.1.0

Track onboarding steps for users when they get setup in your app.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Caleb Porzio

15/01 2018

v1.1

1.1.0.0

Track onboarding steps for users when they get setup in your app.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Caleb Porzio

14/01 2017

v1.0

1.0.0.0

Track onboarding steps for users when they get setup in your app.

  Sources   Download

MIT

The Requires

 

by Caleb Porzio