Dev.

Configuration reference

Every option in config/oi-laravel-settings.php

Configuration reference

Publish the config file:

bash
php artisan vendor:publish --tag=oi-laravel-settings-config
php
return [
    'table' => 'settings',

    'models' => [
        'setting' => \OiLab\OiLaravelSettings\Models\Setting::class,
    ],

    'scope_resolver' => null,
    'default_scope'  => null,

    'cache' => [
        'enabled' => true,
        'store'   => null,
        'prefix'  => 'oi-settings',
        'ttl'     => null,
    ],

    'default_type' => 'string',

    'types' => [
        'string'  => 'string',
        'integer' => 'integer',
        'float'   => 'float',
        'boolean' => 'boolean',
        'json'    => 'json',
        'mail'    => \OiLab\OiLaravelSettings\Data\MailContent::class,
    ],
];

Options

KeyDescription
tableThe settings table name. Also read by the migration.
models.settingThe Eloquent model. Point it at a subclass to add behaviour; always resolved through the OiLaravelSettings resolver.
scope_resolverReturns the current scope. null, a Closure, or an invokable class-string. Prefer Settings::resolveScopeUsing() when using config:cache.
default_scopeScope used when no resolver is set (default null = global).
cache.enabledToggle per-scope map caching.
cache.storeCache store name (null = default store).
cache.prefixCache key prefix.
cache.ttlSeconds to cache, or null to cache forever.
default_typeFallback type when a setting has none.
typesThe type registry: type => primitive keyword or Data class.

Resolving values in code

Never hardcode the model or the type map. Read them through the resolver:

php
use OiLab\OiLaravelSettings\OiLaravelSettings;

OiLaravelSettings::settingModel(); // configured model class
OiLaravelSettings::tableName();
OiLaravelSettings::types();
OiLaravelSettings::defaultType();
Project under MIT License.
Design by