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=config

Creates config/api-tables-config.php. After editing in production:

php artisan config:clear

Full config map

KeyRequiredPurpose
guardsYesWhich auth guards get routes (api, web, spa)
default_middlewaresYesAuth applied to every table (default: auth:sanctum)
tablesYesYour table registry
user_modelFor email reportsUser class for report ownership
general_export_classNoOverride Excel export class
emailFor email reportsMailable, subject, queue
filesystemFor exports/reportsWhere 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

FieldTypeDescription
modelFQCNEloquent model — used for $this->model::query()
tableClassFQCNYour TableAbstract subclass
middlewaresarrayExtra 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

ConcernApproach
Staging vs production tablesSame config — use env-based middleware or policies inside setInitialBuilder()
Multi-tenant scopingPass params from frontend; scope in builder — not separate config entries
Disabling a tableRemove from tables array — do not leave orphaned frontend pages

On this page