Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #17 from PovilasKorop/patch-1
Browse files Browse the repository at this point in the history
Edited README as it is working for me
  • Loading branch information
calebporzio committed Aug 7, 2019
2 parents d57f608 + 2e69807 commit 0f9bec9
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,38 @@ class User extends Model

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

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

class AppServiceProvider extends ServiceProvider
{
// ...

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

Onboard::addStep('Create Your First Post')
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:
```php
@if (Auth::user()->onboarding()->inProgress())
@if (auth()->user()->onboarding()->inProgress())
<div>

@foreach (Auth::user()->onboarding()->steps as $step)
@foreach (auth()->user()->onboarding()->steps as $step)
<span>
@if($step->complete())
<i class="fa fa-check-square-o fa-fw"></i>
Expand Down Expand Up @@ -92,7 +100,7 @@ $onboarding->steps()->each(function($step) {
Definining custom attributes and accessing them:
```php
// Defining the attributes
Onboard::addStep('Step w/ custom attributes')
OnboardFacade::addStep('Step w/ custom attributes')
->attributes([
'name' => 'Waldo',
'shirt_color' => 'Red & White',
Expand Down Expand Up @@ -120,9 +128,9 @@ class RedirectToUnfinishedOnboardingStep
{
public function handle($request, Closure $next)
{
if (Auth::user()->onboarding()->inProgress()) {
if (auth()->user()->onboarding()->inProgress()) {
return redirect()->to(
Auth::user()->onboarding()->nextUnfinishedStep()->link
auth()->user()->onboarding()->nextUnfinishedStep()->link
);
}

Expand Down

0 comments on commit 0f9bec9

Please sign in to comment.