PHP code example of guava / tutorials

1. Go to this page and download the library: Download guava/tutorials library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

guava / tutorials example snippets


use Guava\Tutorials\TutorialsPlugin;

$panel->plugins([
    TutorialsPlugin::make(),
    //
])

use Guava\Tutorials\Concerns\InteractsWithTutorials;
use Guava\Tutorials\Contracts\HasTutorials;
use Guava\Tutorials\Steps\Step;

class CreateProject extends CreateRecord implements HasTutorials
{
    use InteractsWithTutorials;
    
    public function mount(): void
    {
        parent::mount();
        
        $this->mountTutorial();
    }
    
    public function tutorial(Tutorial $tutorial) : Tutorial
    {
        return $tutorial->steps([
            Step::make('name'),
            Step::make('description'),
        ]);
    }
}

$tutorial->steps([
    //
])
->afterMount(
    fn() => // Your code here
)

$tutorial->steps([
    //
])
->afterUnmount(
    fn() => // Your code here
)

$tutorial->steps([
    //
])
->afterSkipped(
    fn() => // Your code here
)

use Guava\Tutorials\Selectors\FormSelector;
use Guava\Tutorials\Selectors\FieldSelector;
use Guava\Tutorials\Selectors\ComponentSelector;

// All variants are the same
Step::make('username');
Step::make(FormSelector::make('username'));
Step::make(FieldSelector::make('username'));
Step::make(ComponentSelector::make('username'));

use Guava\Tutorials\Selectors\WidgetSelector;

// Currently only the "index" of the widget is supported
// So first widget = '1', second widget = '2', etc.
Step::make(WidgetSelector::make('1'));

use \Guava\Tutorials\Selectors\Selector;

Step::make(Selector::make('div'));
Step::make(Selector::make('#my-id'));
Step::make(Selector::make('.my-class'));
Step::make(Selector::make('[data-attribute]'));

Step::make('username')
    ->label('Enter a username');

Step::make('username')
    ->hiddenLabel(true); // or a closure

Step::make('username')
    ->description('Pick an easy-to-remember, unique username');

Step::make('username')
    ->hiddenDescription(true); // or a closure

Step::make('username')
    ->hint('Min. 6 characters');

Step::make('username')
    ->hiddenHint(true); // or a closure

Step::make('username')
    ->color('danger'); // or any other acceptable filament color parameter

Step::make('username')
    ->passThrough(false);

Step::make('username')
    ->interceptClick();

Step::make('username')
    ->nextStepAction(
        fn(NextStepAction $action) =>  // customize $action here
    )
    ->previousStepAction(
        fn(PreviousStepAction $action) =>  // customize $action here
    )
    ->skipTutorialAction(
        fn(SkipTutorialAction $action) =>  // customize $action here
    )
    ->completeTutorialAction(
        fn(CompleteTutorialAction $action) =>  // customize $action here
    );

Step::make('username')
    ->actions([
        PreviousStepAction::make(),
        NextStepAction::make(),
        MyCustomAction::make(),
    ])

use Illuminate\Database\Eloquent\Model;

function (?Model $record) {
    // ...
}

use Guava\Tutorials\Steps\Step;

function (Step $step) {
    // ...
}

use Guava\Tutorials\Tutorial;

function (Tutorial $tutorial) { // or $container
    // ...
}

use Filament\Forms\Components\Component;

function (Component $component) {
    // ...
}

use Filament\Forms\Get;

function (Get $get) {
    // ...
}

use Livewire\Component;

function (Component $livewire) {
    // ...
}

protected function getTutorials() : array
{
    return [
        'simpleTutorial',
        'advancedTutorial',
];
}

public function simpleTutorial(Tutorial $tutorial) : Tutorial
{
    $tutorial->steps([
        //
    ]);
}
    
public function advancedTutorial(Tutorial $tutorial) : Tutorial
{
    $tutorial->steps([
        //
    ]);
}

public function mount(): void
{
    parent::mount();
    
    $this->mountTutorial('simpleTutorial');
}
js
export default {
    presets: [preset],
    content: [
        // ... 
        './vendor/guava/tutorials/resources/**/*.php',
    ],
}