2 Options
Lenny P. edited this page 2026-10-07 08:37:23 +02:00

Options and Table Configuration

Override setupOptions() in the table component:

use RealZone22\PenguTables\Table\Options;

protected function setupOptions(): Options
{
    return parent::setupOptions()
        ->setPerPage(25)
        ->setPerPageOptions([10, 25, 50, 100])
        ->setPrimaryKey('uuid')
        ->withSearch(true)
        ->withBulkActions(true)
        ->withShowItemsPerPage(true)
        ->withLoading(true);
}

Available options

Pagination

->setPerPage(25)
->setPerPageOptions([10, 25, 50, 100])
->setPaginationPages(2)
  • setPerPage() sets the initial page size.
  • setPerPageOptions() controls the page-size choices.
  • setPaginationPages() controls the number of neighboring pagination pages displayed by the package pagination component.

Primary key

->setPrimaryKey('uuid')

The primary key is used for row keys, selection, bulk actions, and selected exports. Set this when the model does not use id.

Search, selection, and loading

->withSearch(false)
->withBulkActions(false)
->withShowItemsPerPage(false)
->withLoading(false)
  • withSearch() enables or disables the global search field.
  • withBulkActions() enables or disables checkboxes and bulk action UI.
  • withShowItemsPerPage() enables or disables the page-size selector.
  • withLoading() enables or disables the loading spinner.

Exports

use RealZone22\PenguTables\Table\ExportTypes;

->withExport(
    true,
    ExportTypes::CSV_ALL,
    ExportTypes::CSV_SELECTED,
)

See Exports for the complete export setup.

Caching

->withCache(
    enabled: true,
    duration: 300,
    keyPrefix: 'users_table',
)

See Caching.

Complete example

protected function setupOptions(): Options
{
    return parent::setupOptions()
        ->setPerPage(50)
        ->setPerPageOptions([25, 50, 100])
        ->setPrimaryKey('id')
        ->withSearch(true)
        ->withBulkActions(true)
        ->withShowItemsPerPage(true)
        ->withLoading(true)
        ->withExport(
            true,
            ExportTypes::CSV_ALL,
            ExportTypes::CSV_SELECTED,
            ExportTypes::XLSX_ALL,
            ExportTypes::XLSX_SELECTED,
        );
}