Skip to content

Configuration & Security

Console Commands (Caching)

To prevent database introspection overhead on every request in production, cache the generated rules.

bash
php artisan laravel-query-engine:cache                   # Scan models and cache all rules
php artisan laravel-query-engine:clear                   # Clear all cached rules
php artisan laravel-query-engine:clear App\Models\User   # Clear rules for a specific model

Configuration Options

After publishing the config file (config/query-engine.php), the following options are available:

KeyEnv VariableDefaultDescription
metadata_connectionQUERY_PARAMS_METADATA_CONNECTIONnullCustom DB connection for schema inspection
caching.enabledQUERY_PARAMS_CACHE_ENABLEDtrueEnable/disable the rules caching layer
caching.ttlQUERY_PARAMS_CACHE_TTL3600Cache time-to-live in seconds
force_cacheQUERY_PARAMS_FORCE_CACHEfalseForce cache usage outside production
debugQUERY_PARAMS_DEBUGfalseLog all generated rules to the Laravel log
pagination.max_limitQUERY_PARAMS_MAX_LIMIT100Strict upper limit for items per page
featuresMultipletrueGlobally enable/disable filters, sorts, includes
allowed_operatorsAll operatorsGlobal whitelist of allowed filter operators
drivers[]Pluggable field resolvers

Security & Visibility

The package is strictly bounded by your model's visibility configuration to prevent data leaks.

  1. $visible (Allow-list): If defined, only these columns can be filtered, sorted, or selected.
  2. $hidden (Deny-list): Columns in this array are strictly forbidden from all query operations.

Pluggable Drivers

Extend the package to handle custom database behaviors by defining a Resolver.

php
// config/query-engine.php
'drivers' => [
    'default' => \App\Support\QueryDrivers\CustomDriver::class,
],

Your driver must implement the Victormgomes\LaravelQueryEngine\Contracts\FieldResolver interface.