jund-fauz / filament-kompact
A set of helper functions and macros in building app using Filament in Laravel
Requires
- php: ^8.3
- brick/math: ^1.0
- filament/filament: ^5.0
- jund-fauz/eloquent-kompact: ^2.0|^3.0
Requires (Dev)
- orchestra/testbench: ^11.3
- orchestra/testbench-dusk: ~11.5.0
- phpunit/phpunit: ^13.0
- zvizvi/filament-column-filters: ^0.0.6
Suggests
- zvizvi/filament-column-filters: Required for the createFilter() column macro
Provides
None
Conflicts
None
Replaces
None
README
A set of helper functions and macros in building app using Filament in Laravel. Built on Eloquent Kompact and its column naming convention.
composer require jund-fauz/filament-kompact
Requires PHP 8.3+, Laravel 13, Filament 5 and Eloquent Kompact 2.0+. The service provider is registered through package discovery.
The column filters need zvizvi/filament-column-filters. It is optional: without it, or while its plugin is not registered on the panel, columns get no filter.
composer require zvizvi/filament-column-filters
Register its plugin on the panel, because the plugin adds the columnFilter() method that this package calls:
use Zvizvi\FilamentColumnFilters\FilamentColumnFiltersPlugin; public function panel(Panel $panel): Panel { return $panel->plugin(FilamentColumnFiltersPlugin::make()); }
Background
Filament Kompact is the second layer extracted from the same Laravel + Filament ERP that produced Eloquent Kompact. Once the models followed the column naming convention, the Filament tables built on top of them started repeating too: the same timestamp columns, the same filters and the same formatting in every resource. KompactTable and the macros here turn those repeated table definitions into defaults derived from the same convention.
Design decisions:
- Build on the convention, don't duplicate it. Column behavior comes from Eloquent Kompact instead of being detected a second time.
- Optional integrations degrade quietly. Column filters use
zvizvi/filament-column-filterswhen it is installed and registered; without it, columns simply get no filter. - Honest versioning. Follows Semantic Versioning.
Where it is used: the table and filter layer of the production ERP it was extracted from.
Scope: this package contains generic tooling only. It holds no business rules, data or credentials from any project that uses it.
Timeline (from the git history): repository created on 2026-11-07, first release 0.1.0 on 2026-11-09, 0.3.1 on 2026-11-11.
Versioning
This package follows Semantic Versioning. Breaking changes are released in a new major version (X.0.0), new backwards-compatible features in a minor version (1.X.0), and bug fixes in a patch version (1.0.X).
Classes and methods marked @internal are not covered by this promise and may change in any release.
KompactTable
Extend KompactTable to build a table with sensible defaults, then call table() from the configure() method that a Filament resource uses:
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; use JundFauz\FilamentKompact\Concerns\KompactTable; class ProductsTable extends KompactTable { protected static array $statsColumns = ['name', 'brand', 'category.name']; public static function configure(Table $table): Table { return static::table($table); } protected static function getColumns(): array { return [ TextColumn::make('name')->searchSortable(), TextColumn::make('brand'), TextColumn::make('category.name'), ]; } }
// ProductResource public static function table(Table $table): Table { return ProductsTable::configure($table); }
The table gets:
- your columns, followed by the timestamp columns;
- a column filter on every column in
$statsColumnsthat has at least one value; - a
TrashedFilter; - record actions: edit and delete for a record, force delete and restore for a trashed record, as icons with a tooltip. A view action is also added, hidden with CSS (turn it off with
getToggledViewAction()); - delete, restore and force delete bulk actions;
- filters, sort and search kept in the session.
Options
| Property | Default | Used for |
|---|---|---|
$statsColumns |
[] |
Columns that get a column filter |
$recordActionOnlyShowIcon |
true |
Show the record actions as icons with a tooltip |
$showTimestamps |
true |
Add the timestamp columns |
$showDeletedAt |
true |
Add the deleted_at column |
$persistInSession |
true |
Keep filters, sort and search in the session |
Hooks
Override these methods to change a part of the table:
| Method | Default |
|---|---|
getColumns() |
[] |
getStatsColumn() |
$statsColumns |
getFilters() |
[TrashedFilter::make()] |
getRecordActions() |
Edit, delete, force delete, restore |
getToggledViewAction() |
true: add the hidden view action |
getToolbarActions() |
Delete, restore and force delete bulk actions |
configureColumnFilter(ColumnFilter $filter, Column $column) |
Nothing. Adjust each column filter, e.g. by $column->getName() |
getModifiedQuery() |
The query unchanged |
Timestamp columns
use JundFauz\FilamentKompact\Table\ColumnTimestamps; $table->columns([ TextColumn::make('name'), ...ColumnTimestamps::tableColumns(), // created_at, updated_at, deleted_at // ...ColumnTimestamps::tableColumns(false) // without deleted_at ]);
The columns are formatted as d-m-Y, H:i, sortable and toggleable. updated_at and deleted_at are hidden by default. created_at gets a date column filter when the zvizvi/filament-column-filters plugin is registered on the panel.
Column filters
Filter::createForColumn() adds a select column filter whose options are the distinct, non-empty values of the column:
use JundFauz\FilamentKompact\Helper\Filter; Filter::createForColumn(TextColumn::make('brand')); TextColumn::make('brand')->createFilter(); // the same, as a macro
The options follow the column name:
| Column | Options |
|---|---|
active_is |
Not active and Active |
weight_gram, stock_pcs, tax_percentage |
Formatted with Format |
status_enum |
The value of the enum |
category.name |
The names of the categories that are used by a record of the table, through a BelongsTo, HasOne or HasMany relation |
Pass the result of Filter::getCount() to skip a column that has no value. It counts the non-empty values of each column in one query:
$stats = Filter::getCount(Product::class, 'brand', 'name'); TextColumn::make('brand')->createFilter($stats);
Other parameters of createForColumn():
| Parameter | Used for |
|---|---|
$searchable |
Also make the column searchable |
$customConfiguration |
fn (ColumnFilter $filter, Column $column), to adjust the filter |
$customFilterOptionConfiguration |
Change the options query of this relational column, see below |
Global configuration
Run a callback on every column filter, e.g. in a service provider:
Filter::configureUsing(function (ColumnFilter $filter, Column $column) { $filter->multiple(); });
Change how the options query of a relational column is built. Take $query and $relationNames by reference and reassign them; $walk is the default walk through the relations:
Filter::resolveOptionQueryUsing(function (&$query, &$relationNames, string $columnName, Closure $walk) { if ($columnName === 'category.name') { $query = Product::query()->where('active_is', true); } });
Configuration
The service provider merges config/filament-kompact.php. Publish it to change the defaults:
php artisan vendor:publish --tag=filament-kompact-config
| Key | Does |
|---|---|
auto-translate |
Calls translateLabel() on every action, field, column and entry |
default-placeholder |
The placeholder used by applying-placeholder-on (null for none) |
applying-placeholder-on |
'column' and/or 'entry' to apply the placeholder on all of them, or 'column' => 'name' to apply it on the one with that name |
use-formatter |
Turns the formatters of TextColumn and TextEntry on or off |
applying-format-on |
The formats to apply, from FormatterConfigKey: wrapName, attributes, signedChange, enum, boolean, gram, pcs, percentage. gram, pcs, percentage, enum and boolean follow the column naming convention (weight_gram, stock_pcs, active_is) |
custom-formatter |
FormatterConfigKey::textColumn / textEntry => ['column_name' => fn ($column) => ...] |
attributes calls attributesSummary() on the record, so list it only when your models have it.
Macros
| Macro | Does |
|---|---|
TextColumn::formatId(string $prefix, ?int $digit = 3) |
Pads the state with 0 and adds the prefix: 5 → INV-005 |
TextEntry::formatId(string $prefix, ?int $digit = 3) |
The same, for an infolist |
TextColumn::formatAddress() / TextEntry::formatAddress() |
Keeps the part of the state after the last comma: Jl. Merdeka 1, Bandung → Bandung |
CreateAction::convertToAdd($icon = null) |
Replaces Buat in the label with Tambah and sets the icon: the argument, else AddAction::iconUsing(), else Heroicon::Plus |
TextColumn::searchSortable($sortableCondition = true, $searchableCondition = true) |
searchable() and sortable() |
Repeater::minItem(int|Closure $count) |
Starts with $count items, requires at least $count, and hides the delete button while at or below $count items |
Column::createFilter(?object $stats = null) |
Filter::createForColumn(), when zvizvi/filament-column-filters is installed. Does nothing while its plugin is not registered on the panel |
TextColumn::make('id')->formatId('INV-'); TextColumn::make('code')->formatId('P-', 5); // 42 → P-00042
Set the icon of every convertToAdd() once, e.g. in a service provider's boot():
AddAction::iconUsing(FontAwesomeIcon::Plus);
Format
Every formatter returns - for a blank value. gram(), pcs() and percentage() also return - for 0 and for a non-numeric string.
| Method | Example |
|---|---|
Format::gram() |
1.2341 → 1.235 gr (3 decimals, rounded up) |
Format::pcs() |
1234567 → 1,234,567 pcs |
Format::percentage() |
12.5 → 12.5% |
Format::carat() |
24 → 24 K |
Format::time() |
08:30:59 → 08:30 |
Every method names its parameter $state, so it can be passed directly to Filament's formatStateUsing() as a first-class callable:
TextColumn::make('weight')->formatStateUsing(Format::gram(...));
Append s to any method name (grams(), pcss(), percentages(), carats(), times()) to format multiple values at once. Multiple arguments return an array of formatted strings; a single argument returns the formatted string directly:
Format::grams('1.2341', 0.5, 0); // ['1.235 gr', '0.500 gr', '-'] Format::pcss(1200); // '1,200 pcs'
Testing
composer test # Unit, Feature and Livewire, as in CI composer test:unit # macros and helpers on their own composer test:feature # pages of a Filament panel requested over HTTP composer test:livewire # pages of a Filament panel driven with Livewire::test() composer test:browser # the same panel in Chrome with Laravel Dusk, local only
The Feature, Livewire and Browser tests run a Filament panel with a ProductResource (tests/Fixtures/Filament) that uses every macro and helper of the package.
The browser tests need Google Chrome and a matching ChromeDriver, installed with vendor/bin/dusk-updater detect --auto-update. They run headless; set DUSK_HEADED=1 to watch them. They are not run in CI.
License
MIT. See LICENSE.