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:

PropertyValue
Keyexport_excel
Limit3,000 rows
ResponseInstant 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"]
}
FieldWhen used
selected_idsExport/action on checked rows only
filtersCurrent table filters — export respects them
emailsRequired for EMAIL_RES actions

When selected_ids is present, the package adds id IN (...) to the query automatically before your callback runs.

Response types

ActionsResponseWithUser experience
INSTANT_RESImmediate JSON or file download
EMAIL_RES"Report queued" — file arrives by email
NOTIFICATION_RESIn-app notification
WEBSOCKET_RESReal-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:

  1. emailReport() in BulkActionsTrait validates row count
  2. Fires EmailReportRequired event
  3. SendEmailReport listener queues job
  4. api-table:email-report command 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,

On this page