定制 nickdekruijk/settings 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nickdekruijk/settings

最新稳定版本:1.2.0

Composer 安装命令:

composer require nickdekruijk/settings

包简介

A basic cache enabled Setting model, migration and helper for your Laravel project

README 文档

README

Latest Stable Version Latest Unstable Version Monthly Downloads Total Downloads License

Settings

A basic cache enabled Setting model, migration and helper for your Laravel project. It uses a database to store settings for your application. When retrieving settings they are stored in the Laravel cache to prevent unnecessary database queries.

Installation

To install the package use

composer require nickdekruijk/settings

Configuration

If you don't like the default configuration options publish the config file and change the settings.php file in your Laravel app/config folder.

php artisan vendor:publish --tag=config --provider="NickDeKruijk\Settings\ServiceProvider"

Usage

Retrieving settings

If the setting table is created (run php artisan migrate) and you added your first setting you can use setting('key'); from anywhere in your application. The setting helper also accepts a default value in case the key isn't present in the database like setting('key', 'defaultvalue');. You can call NickDeKruijk\Settings\Setting::get($key) too.

Retrieving a setting as array

When you have a setting with a value like this:

facebook = https://www.facebook.com/
twitter = https://twitter.com/
instagram = https://instagram.com/

You can have it returned as an array using setting('key', null, '=') which will return this array

[
  "facebook" => "https://www.facebook.com/",
  "twitter" => "https://twitter.com/",
  "instagram" => "https://instagram.com/"
]

Adding settings

To update of create a new setting you use the setting helper with an array like setting(['key' => 'value']); or call NickDeKruijk\Settings\Setting::set([$key => $value]);. To include description you can use setting(['key' => ['value' => 1, 'description' => 'string']]);. The setting will be added to the database or updated if it already exists. The Setting Model also triggers an event on updated and created to store the new value in the cache.

License

Settings is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 704
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-11