qh-8/laravel-options
最新稳定版本:v2.4.0
Composer 安装命令:
composer require qh-8/laravel-options
包简介
Store Laravel application options
关键字:
README 文档
README
This package allows you to store options in a repository (database).
Installation
You can install the package via composer:
composer require qh-8/laravel-options
Usage
Publish the migration file
php artisan vendor:publish --tag=option-migrations
Publish the config file
php artisan vendor:publish --tag=option-config
Create the options table via artisan migrate command
php artisan migrate
Basic usage
// Via helper. option('key', 'default'); // Get an option with default value. option(['key' => 'default']); // Set options. option()->save(); // Delete, update or insert to database. // Via service. $this->app['options']->has('key'); // Check option exists. $this->app['options']->get('key', 'default'); // Get an option with default. $this->app['options']->set('key', 'value'); // Set an option. $this->app['options']->set(['key' => 'value']); // Set many options. $this->app['options']->setMany(['key' => 'value']); // Set many options. $this->app['options']->lock('key'); // Lock an option by key. $this->app['options']->unlock('key'); // Unlock an option by key. $this->app['options']->remove('key'); // Delete an option by key. $this->app['options']->all(); // Get all autoload options. $this->app['options']->toArray(); // Same all(). $this->app['options']->toJSon(); // Same all() but json format. $this->app['options']['key'] // Array access: offsetGet $this->app['options']['key'] = 'value' // Array access: offsetSet. isset($this->app['options']['key']) // Array access: offsetExists. unset($this->app['options']['key']) // Array access: offsetUnset.
Configuration
# Enable autoload options only. OPTIONS_ONLY_AUTOLOAD=true # Eager load options. OPTIONS_EAGER_LOAD=true # Custom model OPTIONS_MODEL=App\Models\Option
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email dqh@dinhquochan.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 873
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-14