How to get all table records in header action
I want to add a header action for my admin panel resource table, where I need to send the records to a blade view to create a pdf export.
What is the best way to get a Collection of the current tables records in a header action?
I tried to do this:
But the looks don't show anything useful:
->headerActions([
Action::make('downloadPdf')
->label('Download Pdf')
->icon('heroicon-o-arrow-down-tray')
->action(function (Collection $records, Table $table, Component $livewire) {
\Log::info('Pdf Export', ['Collection' => $records, 'Table Query' => $table->getQuery(), 'Component' => $livewire]);
}),
])
->headerActions([
Action::make('downloadPdf')
->label('Download Pdf')
->icon('heroicon-o-arrow-down-tray')
->action(function (Collection $records, Table $table, Component $livewire) {
\Log::info('Pdf Export', ['Collection' => $records, 'Table Query' => $table->getQuery(), 'Component' => $livewire]);
}),
])
{"Collection":{"Illuminate\\Support\\Collection":[]},"Table Query":{"Illuminate\\Database\\Eloquent\\Builder":[]},"Component":{"App\\Filament\\Resources\\GroupOrderManagementResource\\Pages\\ListGroupOrderManagement":{"mountedActions":[],"mountedActionsArguments":[],"mountedActionsData":[],"defaultAction":null,"defaultActionArguments":null,"componentFileAttachments":[],"mountedFormComponentActions":[],"mountedFormComponentActionsArguments":[],"mountedFormComponentActionsData":[],"mountedFormComponentActionsComponents":[],"mountedInfolistActions":[],"mountedInfolistActionsData":[],"mountedInfolistActionsComponent":null,"mountedInfolistActionsInfolist":null,"isTableReordering":false,"tableFilters":{"status":{"show_declined":false}},"tableGrouping":null,"tableGroupingDirection":null,"tableSearch":"","tableSortColumn":null,"tableSortDirection":null,"activeTab":"dinner","isTableLoaded":false,"tableRecordsPerPage":10,"tableColumnSearches":[],"toggledTableColumns":[],"mountedTableActions":["downloadPdf"],"mountedTableActionsData":[[]],"mountedTableActionsArguments":[[],[]],"mountedTableActionRecord":null,"defaultTableAction":[],"defaultTableActionArguments":[],"defaultTableActionRecord":[],"selectedTableRecords":[],"mountedTableBulkAction":null,"mountedTableBulkActionData":[],"tableDeferredFilters":null,"paginators":{"page":1}}}}
{"Collection":{"Illuminate\\Support\\Collection":[]},"Table Query":{"Illuminate\\Database\\Eloquent\\Builder":[]},"Component":{"App\\Filament\\Resources\\GroupOrderManagementResource\\Pages\\ListGroupOrderManagement":{"mountedActions":[],"mountedActionsArguments":[],"mountedActionsData":[],"defaultAction":null,"defaultActionArguments":null,"componentFileAttachments":[],"mountedFormComponentActions":[],"mountedFormComponentActionsArguments":[],"mountedFormComponentActionsData":[],"mountedFormComponentActionsComponents":[],"mountedInfolistActions":[],"mountedInfolistActionsData":[],"mountedInfolistActionsComponent":null,"mountedInfolistActionsInfolist":null,"isTableReordering":false,"tableFilters":{"status":{"show_declined":false}},"tableGrouping":null,"tableGroupingDirection":null,"tableSearch":"","tableSortColumn":null,"tableSortDirection":null,"activeTab":"dinner","isTableLoaded":false,"tableRecordsPerPage":10,"tableColumnSearches":[],"toggledTableColumns":[],"mountedTableActions":["downloadPdf"],"mountedTableActionsData":[[]],"mountedTableActionsArguments":[[],[]],"mountedTableActionRecord":null,"defaultTableAction":[],"defaultTableActionArguments":[],"defaultTableActionRecord":[],"selectedTableRecords":[],"mountedTableBulkAction":null,"mountedTableBulkActionData":[],"tableDeferredFilters":null,"paginators":{"page":1}}}}
Solution:
Could be worth a try...Jump to solution
$livewire->getFilteredTableQuery()->get()
$livewire->getFilteredTableQuery()->get()
2 Replies
Solution
Could be worth a try
$livewire->getFilteredTableQuery()->get()
$livewire->getFilteredTableQuery()->get()
Thank you! Exactly what I needed.
I also found this:
Which I think includes all rows, not just the paginated row.
$livewire->getTableRecords()
$livewire->getTableRecords()