承接 danielefavi/laravel-settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

danielefavi/laravel-settings

Composer 安装命令:

composer require danielefavi/laravel-settings

包简介

Laravel package for handling your APP settings.

README 文档

README

Laravel Settings is PHP package for laravel for handling the generic settings of your application.

With Laravel Settings you can store any type of values in the database.

Installation

composer require danielefavi/laravel-settings

Usage

Once the package is installed you can get the Setting model instace from the app service provider like this app('settings') or just call settings() (that is wrapper around app('settings')).

Setting a value

settings()->set('code_langs', ['php', 'javascript', 'python']);

// this does the same of the previous line of code
app('settings')->set('max_connection', 100);

Getting a value

$codeLangs = settings()->get('code_langs');
// codeLangs = Array( [0] => php [1] => javascript [2] => python )

$maxConn = settings()->get('max_connection');

When getting a function you can specify a default value as well.

// if the setting max_connection is not found then it returns 999
$maxConn = settings()->get('max_connection', 999);

Increment a value

settings()->set('counter', 10); // the counter is 10

settings()->inc('counter'); // incrementing the counter by 1, so the counter is 11
settings()->inc('counter'); // incrementing the counter by 1, so the counter is 12
settings()->inc('counter', 3); // incrementing the counter by 3, so the counter is 15

$counter = settings()->get('counter'); // counter == 15

Decrementing a value

settings()->set('counter', 10); // the counter is 10

settings()->dec('counter'); // decrementing the counter by 1, so the counter is 9
settings()->dec('counter', 4); // decrementing the counter by 5, so the counter is 5

$counter = settings()->get('counter'); // counter == 5

Appending (or attaching) a value to a setting

With the attach method you can add values to an existing array or string. If the array or string does not exist then it will be created.

Appending values to an array.

settings()->attach('tags', ['tag-1', 'tag-2']); // attaching (or creating) the array
settings()->attach('tags', ['tag-3', 'tag-4']); // attaching an array to the array
settings()->attach('tags', 'tag-5'); // attaching a value to the array

$tags = settings()->get('tags');
// tags contains tag-1, tag-2, tag-3, tag-4, tag-5

Appending values to a string.

settings()->set('names', 'John');
settings()->attach('names', ',Doe,Wan');
settings()->attach('names', ',Clare');

$names = settings()->get('names'); // John,Doe,Wan,Clare

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固