brnysn/laravel-settings

The simplest way to use system settings in Laravel application.

1.0.1 2022-09-14 10:22 UTC

This package is auto-updated.

Last update: 2022-10-14 10:31:23 UTC


README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require brnysn/laravel-settings

You can publish the config file with:

php artisan vendor:publish --tag="settings-config"

This is the contents of the published config file:

return [
    // 'sample' => 'setting',
];

Add middlewares to your app/Http/Kernel.php file $middlewareGroups array in web group:

protected $middlewareGroups = [
    'web' => [
        // ...
        \Brnysn\LaravelSettings\Http\Middleware\SettingsMiddleware::class,
    ],
    // ...
];

Usage

Get all settings:

use Brnysn\LaravelSettings\Settings;

Settings::all();

Get setting by key:

use Brnysn\LaravelSettings\Settings;

Settings::get('key');

Set setting by key:

use Brnysn\LaravelSettings\Settings;

Settings::set('key', 'value');

Delete setting by key:

use Brnysn\LaravelSettings\Settings;

Settings::delete('key');

Check if setting exists:

use Brnysn\LaravelSettings\Settings;

Settings::has('key');

Flush all settings:

use Brnysn\LaravelSettings\Settings;

Settings::flush();

Use named api routes to see and change settings:

settings.index
settings.update

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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