Bulk actions overview
TableBulkAction, export, and email reports
Bulk actions appear in the table toolbar dropdown. They operate on selected rows and/or current filters — typical examples: export, mass status update, send report email.
Built-in: export_excel
Every table includes this unless you override setBulkActions() without merging parent:
| Property | Value |
|---|---|
| Key | export_excel |
| Limit | 3,000 rows |
| Response | Instant file download (type: stream) |
If the filtered result exceeds 3,000 rows, the user gets an error asking them to use email export instead.
Custom bulk action
use Storageitsolutions\ApisTables\Actions\BulkActions\TableBulkAction;
use Storageitsolutions\ApisTables\Enums\ActionsResponseWith;
protected function setBulkActions(): array
{
return array_merge(parent::setBulkActions(), [
'mark_reviewed' => new TableBulkAction(
tableName: self::TABLENAME,
key: 'mark_reviewed',
label: 'Mark as reviewed',
responseType: ActionsResponseWith::INSTANT_RES,
callbackMethod: 'markReviewed',
need_confirmation: true,
),
]);
}public function markReviewed(Request $request): array
{
$ids = $request->input('selected_ids', []);
$this->model::whereIn('id', $ids)->update(['reviewed_at' => now()]);
return ['success' => true, 'message' => 'Marked as reviewed'];
}Request body (what the client sends)
{
"selected_ids": [1, 2, 3],
"filters": [
{ "field": "status", "operator": "=", "value": "pending" }
],
"emails": ["manager@example.com"]
}| Field | When used |
|---|---|
selected_ids | Export/action on checked rows only |
filters | Current table filters — export respects them |
emails | Required for EMAIL_RES actions |
When selected_ids is present, the package adds id IN (...) to the query automatically before your callback runs.
Response types
ActionsResponseWith | User experience |
|---|---|
INSTANT_RES | Immediate JSON or file download |
EMAIL_RES | "Report queued" — file arrives by email |
NOTIFICATION_RES | In-app notification |
WEBSOCKET_RES | Real-time broadcast |
Email report flow (senior)
For large datasets (up to 100,000 rows):
new TableBulkAction(
self::TABLENAME,
'email_report',
'Email report',
ActionsResponseWith::EMAIL_RES,
callbackMethod: 'emailReport',
additionalPayloadParams: ['emails' => 'required|array|min:1'],
),Pipeline:
emailReport()inBulkActionsTraitvalidates row count- Fires
EmailReportRequiredevent SendEmailReportlistener queues jobapi-table:email-reportcommand generates file and sends mailable
Requirements: user_model, email.* config, running queue worker, export Blade view.
Customizing Excel export
// On your table class
protected $exportView = 'exports.orders';
public function getExcelExportOptions(): array
{
return ['include_charts' => true];
}Override export class globally:
'general_export_class' => App\Exports\CustomApiTableExport::class,