Search by

tranquil-tools / laravel-table-builder

comfycoders-development

Define Laravel tables in PHP: columns, filters, search, sorting, bulk and row actions, export and reordering, independent of any frontend

Package info

github.com/ComfyCodersBV/laravel-table-builder

Homepage

pkg:composer/tranquil-tools/laravel-table-builder

Statistics

Installs: 2 173

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.11.2 2026-12-01 21:12 UTC

This package is auto-updated.

Last update: 2026-12-01 21:17:39 UTC


README

Define Laravel tables in PHP: columns, filters, search, sorting, pagination, totals, bulk and row actions, CSV export and reordering. This package knows nothing about any frontend — it produces a JSON payload that a renderer consumes, and serves the signed bulk-action, reorder and export endpoints.

You probably want the Vue package instead

Unless you are writing a renderer, install tranquil-tools/laravel-vue-table-builder. It requires this package, so you get both:

composer require tranquil-tools/laravel-vue-table-builder

Full documentation lives at docs.comfycoders.nl. This package ships no docs/ directory on purpose: one documentation site, one version stream, no duplication.

What lives here

src/ AbstractTable, TableBuilder, QueryBuilder, components, export, the make:table command
src/Http/, routes/ the signed table.bulk-action, table.reorder and table.export endpoints
config/table-builder.php per page defaults, route middleware, signature lifetime, display timezone, export options
resources/lang/ texts the payload carries, such as the search label and date presets

The boundary rule: what produces the payload belongs here, what renders it belongs in a renderer.

Normalizing the search term

A search input takes a normalize callable that transforms the typed term before it is applied, so a phone number typed as 06 1234 5678 finds 0612345678. It runs on the whole term, before the term is split into words. A result that is empty skips the search input, but still counts as an active search filter. The payload keeps the value as typed, so the schema does not change.

normalizeSearch on column() only works together with searchable: true. A global search bar has one normalizer for all its columns: when columns need different normalizers, register a separate searchInput() per column.

$table->column('phone', searchable: true, normalizeSearch: fn (string $term) => str_replace(' ', '', $term));
$table->withGlobalSearch(columns: ['phone', 'name'], normalize: fn (string $term) => trim($term));
$table->searchInput(key: 'phone', normalize: fn (string $term) => preg_replace('/\D/', '', $term));

Linking a cell

A column takes a url callable that receives the row and returns the url its cell links to, or null for no link on that row. The url is resolved from the rows already loaded, so it adds no queries. A renderer shows the cell as a link that does not trigger the row link.

$table->column('subscribed_count', url: fn (MailingList $list) => route('subscribers.index', [
    'filter' => ['list' => $list->id],
]));

Table density

A table takes density('normal'|'compact'). compact asks the renderer for smaller cell and header padding, so more rows fit on screen. Set it for every table of the app in a service provider; a table's own density() still wins.

TableBuilder::defaultDensity('compact');

$table->density('normal');

The schema contract

TableBuilder::SCHEMA_VERSION is emitted as schemaVersion in every payload. A renderer compares it against the version it supports. Bump the major for changes that would misrender in an older renderer, the minor for additions that can be ignored safely.

Payload additions per version

  • 1.11 (schema 1.9): tables take density('normal'|'compact'), sent as density; TableBuilder::defaultDensity() sets it app-wide.
  • 1.10 (schema 1.8): columns take a url callable. The payload carries columnLinks, per row a map of column key to url, in the same order as rowLinks.
  • 1.9 (schema 1.7): rowLink() takes a method, sent as rowLinkMethod (get by default). A non-GET row link cannot be a modal, a plain href or open in a new tab.
  • 1.7 (schema 1.6): tables take searchPlacement('inline'|'above'), sent as searchPlacement; TableBuilder::defaultSearchPlacement() sets it app-wide.
  • 1.6 (schema 1.5): tables take bulkActionsAlwaysVisible(), sent as bulkActionsAlwaysVisible.
  • 1.5 (schema 1.4): columns take headerClasses and hideBelow (head_class and hide_below in the payload); tables take gridBelow(), sent as gridBelow.
  • 1.4 (schema 1.3): every resolved row action carries rowKey, the row key of its row (the same value as the row's __key), so a consumer matches an action to its row without parsing the url.
  • 1.3 (schema 1.2): row actions take iconOnly, with rowActionsIconOnly() per table and TableBuilder::defaultRowActionsIconOnly() / TableBuilder::defaultRowActionIcons() for the app. Tables take grid(), layout() and layoutToggle(); the payload carries layout, defaultLayout, layoutToggle and queryKeys.layout.
  • 1.2 (schema 1.1): row actions take icon.

The full usage lives in the documentation of the Vue package: row actions, columns and grid layout.

Coming from laravel-vue-table-builder

The namespace TranquilTools\TableBuilder\ did not change, so table classes keep working. Exactly one installed package may claim that namespace: this one.

  • Configuration lives in config/table-builder.php. A published config/vue-table-builder.php is still read and wins over the defaults, and config('vue-table-builder.*') still resolves. Rename the file when convenient.
  • Translations live under table-builder::; vue-table-builder:: keeps resolving to the same files. Overrides published in lang/vendor/vue-table-builder keep applying until a lang/vendor/table-builder directory exists.

Credits

Built by ComfyCoders BV. Licensed under MIT — see LICENSE.md.