Configuration overview
api-tables-config.php reference
Configuration is the registry of every control table in your app. If a table is not listed here, the package cannot resolve it — you will get "Required table Table Not Exists" (where table is the missing name in the URL).
Publish
php artisan vendor:publish --tag=configCreates config/api-tables-config.php. After editing in production:
php artisan config:clearFull config map
| Key | Required | Purpose |
|---|---|---|
guards | Yes | Which auth guards get routes (api, web, spa) |
default_middlewares | Yes | Auth applied to every table (default: auth:sanctum) |
tables | Yes | Your table registry |
user_model | For email reports | User class for report ownership |
general_export_class | No | Override Excel export class |
email | For email reports | Mailable, subject, queue |
filesystem | For exports/reports | Where files are stored |
Tables registry (most important section)
Each entry is one public table name:
'tables' => [
'orders' => [
'model' => App\Models\Order::class,
'tableClass' => App\ApiTables\OrdersTable::class,
'middlewares' => ['admin'],
],
'products' => [
'model' => App\Models\Product::class,
'tableClass' => App\ApiTables\ProductsTable::class,
// no extra middleware — only default_middlewares apply
],
],Field reference
| Field | Type | Description |
|---|---|---|
model | FQCN | Eloquent model — used for $this->model::query() |
tableClass | FQCN | Your TableAbstract subclass |
middlewares | array | Extra middleware — see Guards and middleware |
Naming
The array key (orders) is the tableName in every URL. It must match const TABLENAME = 'orders' in your class.
Example: minimal production config
return [
'guards' => ['api'],
'default_middlewares' => ['auth:sanctum'],
'tables' => [
'users' => [
'model' => App\Models\User::class,
'tableClass' => App\ApiTables\UsersTable::class,
],
],
'user_model' => App\Models\User::class,
'general_export_class' => Storageitsolutions\ApisTables\Exports\GeneralExport::class,
'email' => [
'mail_class' => Storageitsolutions\ApisTables\Mail\NewReportEmail::class,
'subject_prefix' => 'Report: ',
'from_address' => env('MAIL_FROM_ADDRESS'),
'from_name' => env('MAIL_FROM_NAME'),
'template' => 'APITables::mail.ReportEmail',
'queue_connection' => null,
'queue_name' => null,
],
'filesystem' => [
'disk' => 'local',
'path' => 'reports',
],
];Environment-specific tips
| Concern | Approach |
|---|---|
| Staging vs production tables | Same config — use env-based middleware or policies inside setInitialBuilder() |
| Multi-tenant scoping | Pass params from frontend; scope in builder — not separate config entries |
| Disabling a table | Remove from tables array — do not leave orphaned frontend pages |