PHP code example of wallacemartinss / filament-onboarding
1. Go to this page and download the library: Download wallacemartinss/filament-onboarding 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/ */
wallacemartinss / filament-onboarding example snippets
use Wallacemartinss\FilamentOnboarding\FilamentOnboardingPlugin;
$panel->plugins([
FilamentOnboardingPlugin::make()
->launcher() // floating checklist, on every page
->tours() // guided tours
->progressPage() // optional page laying the journey out
->launcherPosition('bottom-right') // bottom-left, top-right, top-left
->modalPosition('center'), // where images and videos open
]);
// app/Onboarding/Conditions/HasActivePlanCondition.php — answers to `has_active_plan`
class HasActivePlanCondition implements OnboardingCondition, HasConditionLabel
{
public static function label(): string
{
return __('Has an active plan'); // what the step editor shows
}
public function isCompleted(Model $subject, ?Model $scope = null): bool
{
return $subject->subscription()?->active() ?? false;
}
}
use Wallacemartinss\FilamentOnboarding\Widgets\OnboardingChecklistWidget;
// In a Dashboard page, or the panel's widgets()
OnboardingChecklistWidget::class,
use Wallacemartinss\FilamentOnboarding\Events\FlowCompleted;
use Wallacemartinss\FilamentOnboarding\Facades\Onboarding;
class MarkSubjectOnboarded
{
public function handle(FlowCompleted $event): void
{
$done = Onboarding::for($event->subject, $event->scope)
->flows()
->every(fn ($flow): bool => $flow->isCompleted());
if ($done) {
$event->subject->forceFill(['onboarded_at' => now()])->save();
}
}
}
// app/Policies/OnboardingFlowPolicy.php
namespace App\Policies;
use App\Models\User;
use Illuminate\Contracts\Auth\Authenticatable;
class OnboardingFlowPolicy extends \Wallacemartinss\FilamentOnboarding\Policies\OnboardingFlowPolicy
{
public function viewAny(Authenticatable $user): bool
{
return $user instanceof User && $user->isAdmin();
}
}
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Gate;
use Wallacemartinss\FilamentOnboarding\Models\OnboardingFlow;
Gate::policy(OnboardingFlow::class, \App\Policies\OnboardingFlowPolicy::class);