Artisan commands

make:api-table and api-table:email-report

The package registers two Artisan commands. You will use make:api-table regularly; api-table:email-report runs via the queue for email exports.

make:api-table

Scaffolds a new table class from the package stub.

php artisan make:api-table OrdersTable

Creates: app/ApiTables/OrdersTable.php (namespace may vary by your app's generator config).

After running the command

Set TABLENAME

const TABLENAME = 'orders';  // must match config key

Register in config

'orders' => [
    'model' => App\Models\Order::class,
    'tableClass' => App\ApiTables\OrdersTable::class,
],

Implement required methods

MethodMinimum implementation
setInitialBuilder()$this->builder = $this->model::query()
$TBLColumnsAt least one column
filters()Return [] initially

Fix constructor if needed

Stub may use:

public function __construct(...$args)
{
    parent::__construct(self::TABLENAME);
}

See Troubleshooting if you get constructor argument errors.

api-table:email-report

Processes email report jobs from the EmailReportRequired event.

php artisan api-table:email-report

Normally you do not run this manually — the queue worker invokes it when a user triggers an email bulk action.

Requirements for email reports to work

RequirementConfig / setup
Queue worker runningphp artisan queue:work
user_model setapi-tables-config.php
Email configemail.mail_class, from_address, etc.
Export viewresources/views/exports/{tableName}.blade.php
Filesystem diskfilesystem.disk and path

Publish tags

CommandOutput
php artisan vendor:publish --tag=configconfig/api-tables-config.php
php artisan vendor:publish --tag=langTranslation files
php artisan vendor:publish --tag=viewsEmail Blade templates

On this page