vluzrmos/eloquent-settings 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

vluzrmos/eloquent-settings

Composer 安装命令:

composer require vluzrmos/eloquent-settings

包简介

An Eloquent Settings Repository

README 文档

README

A package to store settings of your application on database.

Installation

composer require vluzrmos/eloquent-settings

Configuration

First, you have to publish the configs and migrations:

php artisan vendor:publish --provider=Vluzrmos\EloquentSettings\Providers\EloquentSettingsServiceProvider

Second, run the migrations:

php artisan migrate

Usage

You can use the dependency injection or the setting helper:

use \Vluzrmos\EloquentSettings\Setting;

class YourInjectableClass {
   
   protected $settings;
   
   public function __construct (Setting $settings) {
       $this->settings = $settings;   
   }
   
   public function theMethod() {
       $option = $this->settings->get('my.awesome.option', 'default-value');
   }
} 
    

It's more easy to use the setting helper:

// Getter
$option = setting('my.awesome.option', 'default-value');
//or
$option = setting()->get('my.awesome.option', 'default-value');

// Setter
setting()->set('my.awesome.option', 'That is Awesome!');

setting()->save(); //remember, without this the settings will not be stored on database

Setting API

get(string key, mixed default=null) : mixed - Get a setting on database, if doens't exists it will use the default value.

set(string|array key, mixed value=null) : void - Set a value or array of key=>values to the settings.

forget(string key) : void - Clear an value of the settings.

has(string key) : bool - Check if settings has a given key.

all() : array - Get an array of all settings.

except(string|array keys ...) : array - Get settings which doesn't match with that given keys.

only(string|array keys ...) : array - Get settings which match with that given keys.

save() : void - IMPORTANT! Store settings on the database.

update(string|array keys, mixed value=null) : void - Sets and saves one or more settings.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固