Release
tbtop/admin 0.8.2: CSV and XLSX export for tables
Export a table to CSV or XLSX with the filters, search and sort on screen, run bulk actions on every matching row, total columns, let drag reordering run your own write, and exact form types on Node.js. No code changes are needed; review your bulk actions.
0.8.2 lets users take a table with them: an export action downloads its rows as CSV or XLSX, with the filters, search and sort they have on screen. Bulk actions can now run on every matching row, not just the checked page, and columns can show totals. Drag reordering can now hand the write to your own code, so model events, cache flushes and audit logs run. No code changes are needed to upgrade, but review your bulk actions: after "Select all", every one of them, delete included, can now run on all matching rows (see Upgrade below).
Table export
Put ExportAction::make($s) in a table's header actions to export the whole table, or in its bulk actions to export the checked rows, with a switch for every matching row. A click opens a dialog where the user ticks columns and picks a format, and the file carries the table's current tab, search, column search, filters and sort.
$s->table('orders')
->columns([
Column::make('number')->label('Order'),
Column::make('total')->money('USD')
->export(as: fn ($cents) => $cents / 100),
Column::make('note')->export(label: 'Delivery note', enabled: false),
])
->headerActions([ExportAction::make($s)->authorize('export-orders')])
->query(fn () => Order::query());- Values are what the table shows, in CSV and XLSX alike: formatted dates, numbers and money, badge and select labels, booleans as Yes or No.
Column::export()is the one method for a column's file side:labelrenames its header,asreplaces its value, andenabled: falseleaves it unticked in the dialog.- The file streams straight from the query, with no queue.
maxRows, 50 000 by default, refuses a larger export with a message to narrow it down. - Who may export is the action's
authorize(); anyone else gets a 404 from the download endpoint. Without it, everyone who can open the page can export.enabled: falseonly changes the default tick and is not access control. - CSV is UTF-8 with a BOM, and a cell that starts like a formula (
=,+,-,@, a tab or a carriage return) is escaped so a spreadsheet does not run it. - The Node package has the same action:
ExportAction.make(s, { formats, maxRows })and the same CSV and XLSX output.
Bulk actions on every matching row
Once every row on the page is checked and the table has more, the bulk bar offers "Select all 1240". The next bulk action then runs on every row the table's tab, search, column search and filters match. There is nothing to opt into: $ctx->selection holds every matching key, so existing whereKey($ctx->selection) handlers and the delete, restore and force-delete presets act on all of them. Check that this is what you want before you upgrade: a handler that should stay limited to the page can read $ctx->allMatching and refuse. For a big table, $ctx->records() is the table's own query narrowed to the selection, so the work is one statement.
->handle(function (ActionCtx $ctx): Effects {
$count = $ctx->records()->update(['archived_at' => now()]);
return Effects::make()->notify("Archived {$count} order(s)");
}, needs: ['selection'])Column summaries
summarize() adds a totals row under the table: sum, average, min, max and count over every row the filtered query matches, not just the page, formatted like the column's cells. Summary::using() takes your own closure over the filtered query. On a grouped table, each group gets its own subtotal.
Column::make('total')->money('USD')
->summarize(Summary::sum(), Summary::avg('Average order'))Reordering that runs your code
reorderable('sort_order') writes the new order with a query update, so Eloquent events and observers do not fire and a cache keyed on them goes stale. A closure as the second argument now owns the write. It gets the ids in their new order, already checked against the table's query, and may return effects.
->reorderable('sort_order', function (array $ids, Builder $query) {
Pages::reorder($ids);
return Effects::make()->refreshTable('pages')->notify('Order saved');
})Node.js types
FormValuesis exact for translatable, multiple and repeater fields.- A translatable value is typed
Translations<V>, andLocalizedFormValuesgives the same shape with one locale already picked.
Fixes
- On laravel/mcp 1.2, a browser origin a panel allows with
mcpAllowedOrigins()got a 403 from the MCP endpoint. The panel's own origin check is back in charge. admin:install --auth --panel=<id>for a second panel publishes its pages into a directory of their own instead of reporting the first panel's files as existing.
Upgrade
Move tbtop/admin, @tbtop/inertia-admin and, on Node, @tbtop/admin to 0.8.2 together. No code changes are needed. One behaviour to review: every bulk action, delete included, can now run on all matching rows after "Select all", not only the checked page. The new features are in the docs for export, summaries, bulk actions and reordering. Every change is in the changelog. Import, and exports that run in the background, are next on the roadmap.