mjpakzad/laravel-settings
最新稳定版本:v1.0.0
Composer 安装命令:
composer require mjpakzad/laravel-settings
包简介
The laravel settings package let you save your settings in the database and access them easily.
关键字:
README 文档
README
The laravel settings package let you save your settings in the database and access them easily.
install
Add this package to your project using composer
composer require mjpakzad/laravel-settings
Publish the migration file
php artisan vendor:publish --provider="Mjpakzad\LaravelSettings\SettingServiceProvider"
Migrate the new migration to create settings table
php artisan migrate
Usage
Create a new setting
set_setting($key, $value, $group, $autoload)
You can group settings for example footer-settings or seo or anything else, default value of $group is null.
Also, you can autoload some settings to load in your AppServiceProvider, default value of $autoload is false.
examples
set_setting('site-name', 'Laravel settings')
set_setting('blog-title', 'My personal blog', 'blog', true)
Get a value by key
get_setting('site_name')
Get values by group
setting_group('blog')
Get autoload settings
setting_autoload($autoload)
default value of $autoload is true
Also, you can bring all settings out to config.
setting_config()
This function save all settings as key-value pairs in config, you can filter settings by parameters like below:
setting_config($keys, $groups, $autoload)
All parameters have null value.
Now, you can access them by config() method:
config('settings')
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-16