cloudcake/laravel-settings 问题修复 & 功能扩展

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

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

cloudcake/laravel-settings

Composer 安装命令:

composer require cloudcake/laravel-settings

包简介

Associate generic data to any other model without polluting your application model logic.

README 文档

README

Settings is a package to assist in associating settings or attributes of JSON form to any of your models using polymorphic relationships.

Usage

Publish Migrations

php artisan vendor:publish --provider="Settings\Providers\SettingsServiceProvider" \
                           --tag="migrations"

Setup models with settings

Add the \Settings\Traits\HasSettings trait to any model that should have settings.

use Settings\Traits\HasSettings;

class User extends Model
{
    use HasSettings;
}

Creating Settings

Global Settings

use Settings\Models\Setting;

Setting::make('config', [
  'rateLimit' => true,
  'ipLocks'   => [
    '127.0.0.1',
    '10.0.0.1'
  ]
]);

Model Specific Settings

use Settings\Models\Setting;

Setting::make('preferences', [
  'notifications'    => true,
  'backgroundColour' => '#ffffff'
], \App\User::class);

Attaching Settings

When attaching settings, any fields not provided will receive the default values.

\App\User::find(1)->attachSetting('preferences', [
  'notifications' => false,
]);

The above will set notifications to true while backgroundColour will be inherited from the original setting. If the global setting is changed, the user's setting will return the changed setting.

Getting Settings

Get All Fields

\App\User::first()->setting('preferences');

Get Specific Field

\App\User::first()->setting('preferences')->get('notifications');

Modifying Settings

\App\User::first()->setting('preferences')->set('notifications', true);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固