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

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

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

mehdikhody/laravel-options

Composer 安装命令:

composer require mehdikhody/laravel-options

包简介

Global key-value store for laravel.

README 文档

README

Introduction

Sometimes you need to create a global key-value store to put your website settings and options that you may change later on the fly without editing your .env file everytime you make a change.

Installation

To get started with laravel-options use composer to add the package to your composer.json file:

composer require mehdikhody/laravel-options

And execute the migration command to create the options table:

php artisan migrate

To customise table name or set some default options, you can publish our config file using the following command:

php artisan vendor:publish --provider="Mehdikhody\Options\Providers\OptionsServiceProvider"

After that, laravel would generate a config file named option.php in the config directory.

return [
    'table' => 'options',
    'options' => [
        'tax_fee' => 0.28,
        'is_shop_open' => true
    ]
];

If you made a change to the default options later on (after migration), you can run this command to update the options table accordingly.

php artisan option:seed

Usage

There is three-way that you can choose from:

  1. Mehdikhody\Options\Facades\Option Facade.
  2. helper functions like: option_set($key, $value)
  3. command line like: php artisan option:set key value

Creat or update an option

Set a given option value.

Option::set('name', 'Jon Doe');
option_set('tax_fee', 0.3);

Check if an option exists

Determine if the given option value exists.

$hasName = Option::has('name');         // true
$hasAge = option_has('age');            // false

Get an option

Get the specified option value.

$name = Option::get('name');            // Jon Doe
$age = option_get('age', 26);           // 26

Delete an option

Delete the specified option value.

Option::remove('name');
option_remove('age');

Delete all the options

Delete all the options and restore the default options in the config/option.php.

Option::clear();
option_clear();

Get an option model

Get the option model instance to access data like created_at or updated_at.

$model = Option::getModel('tax_fee'); // or option_get_model('tax_fee')
$created_at = $model->created_at;
$updated_at = $model->updated_at;

Console commands

It is also possible to do everything above within the console:

php artisan option:set key value
php artisan option:get key
php artisan option:has key
php artisan option:remove key
php artisan option:info key
php artisan option:all
php artisan option:clear
php artisan option:seed

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固