dalholm/laravel-settings

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

一个简单而强大的Laravel设置包,具有回退和缓存选项。

安装

您可以通过composer安装此包

composer require dalholm/laravel-settings

发布

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

配置

/*
 * 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' => [
        //
    ],

];

使用方法

// 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');

更新日志

请参阅更新日志以获取最近更改的更多信息。

贡献

请参阅贡献指南以获取详细信息。

安全

如果您发现任何安全相关的问题,请通过电子邮件mikael@dalholm.se联系,而不是使用问题跟踪器。

致谢

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。

Laravel 包模板

此包是用Laravel 包模板生成的。