Enum Integration
PHP enums that implement HasTableDisplay get first-class badge rendering with automatic text labels and colours.
Implementing the Interface
php
use Forjed\InertiaTable\Contracts\HasTableDisplay;
enum ServerStatus: string implements HasTableDisplay
{
case Active = 'active';
case Failed = 'failed';
case Pending = 'pending';
public function getText(): string
{
return match ($this) {
self::Active => 'Active',
self::Failed => 'Failed',
self::Pending => 'Pending',
};
}
public function getColor(): string
{
return match ($this) {
self::Active => 'success',
self::Failed => 'danger',
self::Pending => 'warning',
};
}
}Using in a Table
php
use Forjed\InertiaTable\Columns\EnumColumn;
// Using the typed column
EnumColumn::make('status', 'Status')->sortable()
// Or using the base Column with modifier
Column::make('status', 'Status')->sortable()->enum()How It Works
getText()is used as the display value in the badgegetColor()determines the badge variant (success,danger,warning,info,default,outline)- If the value is not a
HasTableDisplayinstance, it falls back to the raw value
Available Colours
The frontend maps colour names to Tailwind classes:
| Colour | Light Mode | Dark Mode |
|---|---|---|
success | Green badge | Green badge (dark) |
danger | Red badge | Red badge (dark) |
warning | Yellow badge | Yellow badge (dark) |
info | Blue badge | Blue badge (dark) |
default | Gray badge | Gray badge (dark) |
outline | Transparent with border | Border (dark) |