← Back to Plugins
  • Badgeable Column
  • Badgeable Column

Badgeable Column

Plugin information

by Adam Weston • 12 stars

Column Table builder Admin panel

Badgeable Column allows you to add badges to columns that appear at the end of the column's value.

Support

#badgeable-column on Discord

Views

660

License

MIT

Documentation

Installation

You can install the package via composer:

composer require awcodes/filament-badgeable-column

Optionally, you can publish the views, translations and assets using

php artisan vendor:publish --tag="filament-badgeable-column-views"
php artisan vendor:publish --tag="filament-badgeable-column-translations"
php artisan vendor:publish --tag="filament-badgeable-column-assets"

Usage

BadgeableColumn extends Filament's own TextColumn so it supports all methods used by TextColumn.

use Awcodes\FilamentBadgeableColumn\Components\Badge;
use Awcodes\FilamentBadgeableColumn\Components\BadgeField;
use Awcodes\FilamentBadgeableColumn\Components\BadgeableColumn;
 
return $table
->columns([
BadgeableColumn::make('title')
->badges([
Badge::make('front_page')
->label('Front Page')
->color('success')
->visible(fn ($record): bool => $record->front_page),
Badge::make('front_page_custom_color')
->label('#bada55')
->color('#bada55')
->visible(fn ($record): bool => $record->front_page),
Badge::make('trashed')
->label('Trashed')
->color('danger')
->visible(fn ($record): bool => $record->deleted_at ?? false),
BadgeField::make('status')
->options([
'Draft' => 'Draft',
'Review' => 'In Review',
'Published' => 'Published'
])
->colors([
'gray' => 'Draft',
'warning' => 'Review',
'success' => 'Published',
])
->visible(fn ($record): bool => $record->status !== Status::Published->name)
])
->searchable()
->sortable(),
]);