jason-xt/lara-setting

This package is abandoned and no longer maintained. The author suggests using the jason-xt/lara-setting package instead.

A persistent settings package for Laravel 6.0+ with manager api and interface

0.1.0 2019-12-24 02:17 UTC

This package is auto-updated.

Last update: 2021-06-06 10:31:27 UTC


README

Latest Version on Packagist Software License Total Downloads

Laravel 设置持久化工具包 / A persistent settings package for Laravel 6.0+

后台管理 / Setting manage interface

avatar


  • 数据库存储 / Database persistent
  • Laravel 框架自带缓存 / Cache by Laravel framework
  • 运行时缓存 / Runtime cache (Get from cache or db one time during Request Lifecycle)

Install

Via Composer

$ composer require xtrees/lara-setting

$ php artisan vendor:publish --tag=config
$ php artisan vendor:publish --tag=migrations
$ php artisan migrate

Config

return [
    //Use framework's cache drive
    'cache' => [
        'mode' => 'batch',
        'enable' => true,
        'prefix' => 'settings:',
        //cache time .minutes
        'ttl' => 60,
    ],
    //Facade name   LaraSetting::get(..)
    'facade' => 'LaraSetting',
];

Usage

//Helper funtion
settings('group.key')

//Create or update setting in  DB/cache/runtime 
LaraSetting::set('group.key', 'setting-value');

//Get the setting from runtime/cache/DB
LaraSetting::get('group.key');

//Remove setting
LaraSetting::forget('group.key');

License

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