定制 laraveleg/options 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

laraveleg/options

Composer 安装命令:

composer require laraveleg/options

包简介

You can create options, reuse them and rely on them at a later time. Inspired by the WordPress system and built on the Laravel framework

README 文档

README

Software License Travis Total Downloads

You can create options, reuse them and rely on them at a later time. Inspired by the WordPress system and built on the Laravel framework.

Install for laravel

composer require laraveleg/options

Install for lumen

composer require laraveleg/options

Register service provider

Go to bootstrap/app.php file and add the following line

$app->register(LaravelEG\LaravelOptions\LumenOptionsServiceProvider::class);

Migrate options table

php artisan migrate

Usage

You can manage options in a simple way by helpers.

Cache Mode

add_option

You can add an option through the following line :-

add_option($key, $value, $expiration);

$key: The option ID that you will use to fetch its value.

$value: Put the value of any type of data.

$expiration: Expiration date. This can be unused and saved all the time. Ex: add_option($key, $value).

get_option

Fetching value for a specific option :-

get_option($key, $default)

$key: The option ID. $default: You can specify a default value if the option is not found.

has_option

Make sure the option is there :-

has_option($key)

$key: The option ID.

remove_option

You can delete any option :-

remove_option($key)

$key: The option ID.

Eloquent Mode

You can put the settings to a specific element in a specific model.

Vendor publish

php artisan vendor:publish --provider="LaravelEG\LaravelOptions\LaravelOptionsServiceProvider"

Migrate options table

php artisan migrate

Set config

Go to laraveloptions.php file in configs directory

'eloquent_mode' => true, // Enable Eloquent Mode

Use for model

Add the trait in your specific model.

use LaravelEG\LaravelOptions\Traits\HasLaravelEGOptions;

class Unit extends Model
{
    use HasLaravelEGOptions;

add_option

You can add an option through the following line :-

$unit = Unit::find(1);
$unit->addOption($key, $value, $expiration);

$key: The option ID that you will use to fetch its value.

$value: Put the value of any type of data.

$expiration: Expiration date. This can be unused and saved all the time. Ex: add_option($key, $value).

get_option

Fetching value for a specific option :-

$unit = Unit::find(1);
$unit->getOption($key, $default)

$key: The option ID. $default: You can specify a default value if the option is not found.

has_option

Make sure the option is there :-

$unit = Unit::find(1);
$unit->hasOption($key)

$key: The option ID.

remove_option

You can delete any option :-

$unit = Unit::find(1);
$unit->removeOption($key)

$key: The option ID.

You an use this Trait in any model on your app.

Command-lines

Remove all options

php artisan laraveleg:options:remove-all

Remove all options on eloquent mode

Testing

Run the tests with:

vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email komicho1996@gmail.com instead of using the issue tracker.

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固