outerweb/settings

This package adds application wide settings stored in your database.

v1.0.3 2024-03-12 20:47 UTC

This package is auto-updated.

Last update: 2024-11-12 22:05:56 UTC


README

Latest Version on Packagist Total Downloads

This package adds application wide settings stored in your database.

Installation

You can install the package via composer:

composer require outerweb/settings

Run the install command:

php artisan settings:install

Usage

Saving settings

You can save settings using the helper function setting():

setting(['key' => 'value']);

You can also save multiple settings at once:

setting([
    'general.key1' => 'value1',
    'general.key2' => 'value2',
]);

// Returns
[
    'general.key1' => 'value1',
    'general.key2' => 'value2',
]

Retrieving settings

You can retrieve settings using the helper function setting():

setting(string $key, mixed $default = null);

// Example
setting('key', 'default');

// Returns
'value' // or 'default' if the key does not exist

The key can be a dot-notation key to retrieve nested settings:

setting('general.key1');

// Returns
'value1'

If you have multiple settings with the same parent key, you can retrieve them all at once:

setting('general');

// Returns
[
    'key1' => 'value1',
    'key2' => 'value2',
]

You can also retrieve all settings at once:

setting('*');

// Returns
[
    'key' => 'value',
    'general' => [
        'key1' => 'value1',
        'key2' => 'value2',
    ],
]

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

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