<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cuongpham2107 / filament-theme-customizer example snippets
use CuongPham\FilamentThemeCustomizer\ThemeCustomizerPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
ThemeCustomizerPlugin::make()
// Optional: button position ('bottom-right' or 'bottom-left', default: 'bottom-right')
->position('bottom-right')
// 1. Permission to customize and save personal preferences to DB
->canCustomize(fn (): bool => auth()->check())
// 2. Permission for Super Admin to set the System-Wide Global Default
->canSetGlobalDefault(fn (): bool => auth()->user()?->hasRole('super_admin') ?? false)
);
}
// Grant access only to Super Admins
ThemeCustomizerPlugin::make()
->canCustomize(fn (): bool => auth()->user()?->can('manage_theme') ?? false)
// Only enable in local development
ThemeCustomizerPlugin::make()
->canCustomize(app()->isLocal())
// Dependency injection in closure
ThemeCustomizerPlugin::make()
->canCustomize(function (?\App\Models\User $user): bool {
return $user && $user->is_admin;
})