Show Balance from your API or any source, displaying directly in the Header of your Filament.
Plugin Version | Filament Version | PHP Version |
---|---|---|
1.x | ^2.9.15 | > 8.0 |
2.x | 3.x | > 8.1 |
composer require lukasccb/filament-balance-header
To use this plugin register it in your panel configuration:
use lukasccb\FilamentBalanceHeader\ApiBalanceHeaderPlugin;
$panel
->plugins([
ApiBalanceHeaderPlugin::make()->balance("R$ 0.00"),
]);
You can customize any behaviour via the plugin object.
Use php artisan vendor:publish --tag="filament-balance-header-views"
to publish the view to the resources/views/vendor/filament-balance-header
folder. After this you can customize it as you wish!
By default, the package checks whether you have Spatie permissions plugin installed and checks for a role called super_admin
. You can further customize whether the indicators should be shown.
use lukasccb\FilamentBalanceHeader\ApiBalanceHeaderPlugin;
$panel->plugins([
ApiBalanceHeaderPlugin::make()->balance("R$ 0.00")
->visible(fn () => auth()->user()?->can('see_indicator'))
]);
Or with Roles
use lukasccb\FilamentBalanceHeader\ApiBalanceHeaderPlugin;
$panel->plugins([
ApiBalanceHeaderPlugin::make()->balance("R$ 0.00")
->visible(fn () => auth()->user()?->role('admin'))
]);
You can overwrite the default colors if you want your own colors or need to add more. The ->color()
method accepts any Filament's Color object or a closure that returns a color object.
use lukasccb\FilamentBalanceHeader\ApiBalanceHeaderPlugin;
use Filament\Support\Colors\Color;
$panel->plugins([
ApiBalanceHeaderPlugin::make()
->color(fn () => match (app()->environment()) {
'production' => null,
'staging' => Color::Orange,
default => Color::Blue,
})
]);
By default, both are displayed. You can turn them off separately.
use lukasccb\FilamentBalanceHeader\ApiBalanceHeaderPlugin;
use Filament\Support\Colors\Color;
$panel->plugins([
ApiBalanceHeaderPlugin::make()
->showBadge(false)
->showBorder(true)
]);
Now, run composer update
.