PHP code example of rolland97 / filament-tours

1. Go to this page and download the library: Download rolland97/filament-tours 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/ */

    

rolland97 / filament-tours example snippets


FilamentToursPlugin::make()->tours([
    Tour::make('create-request')
        ->for(CreateRequest::class)
        ->once()
        ->steps([
            Step::make('#data\\.title')
                ->title('Give it a name')
                ->body('Something your team will recognise in a list.'),

            Step::make('[data-tour="items"]')
                ->title('Add your items')
                ->body('One row per thing you need.')
                ->side('left'),
        ]),
])

use Filament\Panel;
use Rolland\FilamentTours\FilamentToursPlugin;
use Rolland\FilamentTours\Step;
use Rolland\FilamentTours\Tour;

public function panel(Panel $panel): Panel
{
    return $panel
        // …
        ->plugin(
            FilamentToursPlugin::make()->tours([
                Tour::make('dashboard-intro')
                    ->for(Dashboard::class)
                    ->once()
                    ->steps([
                        Step::make('[data-tour="stats"]')
                            ->title('Your numbers')
                            ->body('Updated hourly.'),
                    ]),
            ]),
        );
}

Tour::make('create-request')
    ->for(CreateRequest::class)
    ->manual()
    ->once()
    ->steps([...])

Step::make('[data-tour="items"]')

FilamentToursPlugin::make()
    ->buttonLabels([
        'next' => fn (): string => __('tours.next'),
        'previous' => fn (): string => __('tours.previous'),
        'done' => fn (): string => __('tours.done'),
    ])
    ->tours([...])

Step::make('#data\\.title')
    ->title(fn (): string => __('tours.request.title.heading'))
    ->body(fn (): string => __('tours.request.title.body'))

use Rolland\FilamentTours\Actions\StartTourAction;

protected function getHeaderActions(): array
{
    return [
        StartTourAction::make('dashboard-intro')->label('Show me around'),
    ];
}

use Rolland\FilamentTours\Contracts\TourState;

class DatabaseTourState implements TourState
{
    public function hasSeen(string $tourId): bool
    {
        return auth()->user()->seen_tours[$tourId] ?? false;
    }

    public function markSeen(string $tourId): void
    {
        $user = auth()->user();
        $user->seen_tours = [...$user->seen_tours, $tourId => true];
        $user->save();
    }
}

// config/filament-tours.php
'state' => \App\Support\DatabaseTourState::class,
bash
> composer filament:assets
> 
bash
php artisan vendor:publish --tag="filament-tours-config"
bash
php artisan tours:list