sinclairt/settingable

在数据库中存储应用或资源的设置

1.0.6 2017-03-29 12:25 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:01:17 UTC


README

安装

  • 运行 composer require sinclairt/settable
  • config\app.php 中的 providers 数组中注册 Sinclair\Settable\SettableServiceProvider::class
  • 运行 composer dump-autoload
  • 运行 php artisan vendor:publish。这将发布设置迁移。
  • 运行 php artisan migrate

使用方法

设置可以是全局的或资源特定的,对于全局设置,以下示例中的 $myObject 可以省略或设置为 null,否则包含您需要的设置的对象。

获取

简写:setting('some_key') 将返回 'some_key' 值。这将只返回全局设置,对于资源设置,请使用替代方法。

替代:app('Settable')->get('some_key', $myObject, 'my_default')setting()->get(...)

它将检查值是否为回调并返回回调的值。

设置

简写:setting(['some_key', 'some_value', $myObject]) 将将 'some_key' 键设置为 'some_value' 并返回布尔值。

替代:app('Settable')->set('some_key', 'my_value', $myObject)setting()->set(...)

存在

app('Settable')->exists('some_key', $myObject)setting()->exists(...)返回布尔值