Beartropy Tables

Bulk Actions
Enable row selection with checkboxes and perform bulk operations on selected data.

Enable Bulk Selection

Add checkbox selection to every row.

Enable Checkboxes

hasBulk(bool $bool) — Adds a checkbox column to the table. A "select all" checkbox appears in the header.

1$this->hasBulk(true);

Show Options on Selection

showOptionsOnlyOnRowSelect() — Hides the options/actions dropdown until at least one row is selected. Keeps the UI clean when no action is needed.

1$this->showOptionsOnlyOnRowSelect();

Combine with options()

Bulk selection is most useful when combined with the options() method. Define actions like export, delete, or status changes that operate on the selected rows.

Accessing Selected Data

Retrieve selected row IDs or full data objects.

Get Selected Row IDs

getSelectedRows() — Returns an array of IDs for all currently selected rows. Use this for database operations like bulk updates or deletes.

1$selectedIds = $this->getSelectedRows();

Get Selected Data Objects

getSelectedOriginalData() — Returns selected rows with raw database values.

getSelectedData() — Returns selected rows with column formatting applied.

1// Returns raw values
2$rawData = $this->getSelectedOriginalData();
3 
4// Returns formatted values
5$formattedData = $this->getSelectedData();

Clear Selection

emptySelection() — Deselects all rows. Call this after completing a bulk action to reset the UI.

1$this->emptySelection();

Complete Example

A working table with bulk selection and three action options.

BulkUsersTable.php

This example from the playground demonstrates bulk actions with export to clipboard, deactivate, and delete operations — including empty-selection guards and emptySelection() cleanup.

1use App\Models\User;
2use Beartropy\Tables\Classes\Columns\Column;
3use Beartropy\Tables\Classes\Columns\DateColumn;
4use Beartropy\Tables\YATBaseTable;
5 
6class BulkUsersTable extends YATBaseTable
7{
8 public $model = User::class;
9 
10 public function columns(): array
11 {
12 return [
13 Column::make('Name', 'name')->sortable()->searchable(),
14 Column::make('Email', 'email')->sortable()->searchable(),
15 DateColumn::make('Created', 'created_at')
16 ->outputFormat('M d, Y'),
17 ];
18 }
19 
20 public function options(): array
21 {
22 return [
23 'exportSelected' => ['label' => 'Export to Clipboard', 'icon' => '📋'],
24 'deactivateSelected' => ['label' => 'Deactivate Selected', 'icon' => '🚫'],
25 'deleteSelected' => ['label' => 'Delete Selected', 'icon' => '🗑️'],
26 ];
27 }
28 
29 public function exportSelected(): void
30 {
31 $data = $this->getSelectedData();
32 if ($data->isEmpty()) {
33 $this->dispatch('toast', message: 'No rows selected.', type: 'warning');
34 return;
35 }
36 $this->exportToClipboard($data);
37 $this->dispatch('toast', message: $data->count() . ' rows copied.', type: 'success');
38 }
39 
40 public function deactivateSelected(): void
41 {
42 $ids = $this->getSelectedRows();
43 if (empty($ids)) { return; }
44 User::whereIn('id', $ids)->update(['email_verified_at' => null]);
45 $this->emptySelection();
46 }
47 
48 public function deleteSelected(): void
49 {
50 $ids = $this->getSelectedRows();
51 if (empty($ids)) { return; }
52 User::whereIn('id', $ids)->delete();
53 $this->emptySelection();
54 }
55 
56 public function settings(): void
57 {
58 $this->hasBulk(true);
59 $this->showOptionsOnlyOnRowSelect();
60 $this->setPerPageDefault(15);
61 }
62}

Live Demo

Try it — select rows with checkboxes, then use the dropdown actions.

Bulk Selection Table

Bulk Actions
#
Name
Email
Role
Created
1
Alice Johnson alice@example.com Admin Jan 15, 2024
2
Bob Smith bob@example.com Editor Feb 20, 2024
3
Carol White carol@example.com Viewer Mar 10, 2024
4
David Brown david@example.com Editor Apr 05, 2024
5
Eva Martinez eva@example.com Admin May 22, 2024
6
Frank Lee frank@example.com Viewer Jun 18, 2024
7
Grace Kim grace@example.com Editor Jul 03, 2024
8
Henry Davis henry@example.com Admin Aug 29, 2024
1<livewire:tables.demos.demo-bulk-table />
Beartropy Logo

© 2026 Beartropy. All rights reserved.

Provided as-is, without warranty. Use at your own risk.