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 OrdersTableCreates: 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 keyRegister in config
'orders' => [
'model' => App\Models\Order::class,
'tableClass' => App\ApiTables\OrdersTable::class,
],Implement required methods
| Method | Minimum implementation |
|---|---|
setInitialBuilder() | $this->builder = $this->model::query() |
$TBLColumns | At 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-reportNormally 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
| Requirement | Config / setup |
|---|---|
| Queue worker running | php artisan queue:work |
user_model set | api-tables-config.php |
| Email config | email.mail_class, from_address, etc. |
| Export view | resources/views/exports/{tableName}.blade.php |
| Filesystem disk | filesystem.disk and path |
Publish tags
| Command | Output |
|---|---|
php artisan vendor:publish --tag=config | config/api-tables-config.php |
php artisan vendor:publish --tag=lang | Translation files |
php artisan vendor:publish --tag=views | Email Blade templates |