dalholm/laravel-settings

Database settings package for Laravel

v0.5 2024-04-17 11:26 UTC

This package is auto-updated.

Last update: 2024-09-17 12:16:47 UTC


README

Latest Version on Packagist Total Downloads

Simple and powerful settings package for laravel with fallback and cache option.

Installation

You can install the package via composer:

composer require dalholm/laravel-settings

Publish

php artisan vendor:publish --tag=laravel-settings

Config

/*
 * You can place your custom package configuration in here.
 */
return [

    /*
    |--------------------------------------------------------------------------
    | Cache
    |--------------------------------------------------------------------------
    | Cache is only working with redis and uses cache tags
    |
    */

    'cache' => [
        'enabled' => env('SETTINGS_CACHE_ENABLED', false),
        'profile' => Dalholm\LaravelSettings\Cache\CacheProfile::class,
        'store' => null,
    ],

    /*
    |--------------------------------------------------------------------------
    | Database settings
    |--------------------------------------------------------------------------
    | You could use what ever you want
    |
    */
    'database' => [
        'connection'    => null,
        'table'         => 'settings',
        'key'           => 'key',
        'value'         => 'value',
    ],

    /*
    |--------------------------------------------------------------------------
    | Fallback
    |--------------------------------------------------------------------------
    | Use this as a fallback if settings is not yet available in database
    |
    | Example:
    |       "power" => "is-on"
    |
    */

    'fallback' => [
        //
    ],

];

Usage

// Create / update setting or settings
// Settings will automatically update database and replace cache
settings(['key' => 'value']);


// Create / update multple
settings([
   'key 1' => 'value 1',
   'key 2' => 'value 2',
   'key 3' => 'value 3',
   // etc 
]);


// Get
settings('key');

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mikael@dalholm.se instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.