Skip to content

LukasCCB/filament-balance-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Filament Header Balance

Latest Version on Packagist Software License GitHub Workflow Status Total Downloads

Show Balance from your API or any source, displaying directly in the Header of your Filament.

Screenshot

Installation via Composer

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

Usage

To use this plugin register it in your panel configuration:

use lukasccb\FilamentBalanceHeader\ApiBalanceHeaderPlugin;

$panel
    ->plugins([
        ApiBalanceHeaderPlugin::make()->balance("R$ 0.00"),
    ]);

Configuration

You can customize any behaviour via the plugin object.

Customizing the view

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!

Visibility

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'))
]);

Colors

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,
        })
]);

Indicators

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.

Credits by Plugin Base

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published