承接 appstract/laravel-options 相关项目开发

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

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

appstract/laravel-options

最新稳定版本:7.0.0

Composer 安装命令:

composer require appstract/laravel-options

包简介

Global options loaded from the database

README 文档

README

Latest Version on Packagist Total Downloads Software License

Global key-value store in the database

Installation

To get started with laravel-options, use Composer to add the package to your project's dependencies:

composer require appstract/laravel-options

Publish, migrate

By running php artisan vendor:publish --provider="Appstract\Options\OptionsServiceProvider" in your project all files for this package will be published. For this package, it's only a migration. Run php artisan migrate to migrate the table. There will now be an options table in your database.

Usage

With the option() helper, we can get and set options:

// Get option
option('someKey');

// Get option, with a default fallback value if the key doesn't exist
option('someKey', 'Some default value if the key is not found');

// Set option
option(['someKey' => 'someValue']);

// Remove option
option()->remove('someKey');

// Check the option exists
option_exists('someKey');

If you want to check if an option exists, you can use the facade:

use Option;

$check = Option::exists('someKey');

The helpers are available as Blade directives:

@option('someKey')

@option('someKey', 'Default value')

@optionExists('someKey')
    // Code
@endif

Console

It is also possible to set options within the console:

php artisan option:set {someKey} {someValue}

Testing

$ composer test

Contributing

Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 732
  • Watchers: 18
  • Forks: 67
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-10