larsjanssen6/increment-decrement 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

larsjanssen6/increment-decrement

Composer 安装命令:

composer require larsjanssen6/increment-decrement

包简介

Simple ways of incrementing/decrementing and sorting rows

README 文档

README

Software License StyleCI Scrutinizer Code Quality Build Status

This Laravel >=5.4 package allows you to sort your rows very easy. You can play with the rows in a lot of ways.

Example:

demo

Once installed you can do the following:

Order::increment($model);
Order::decrement($model);
Order::toFirst($model);
Order::toLast($model);
Order::toMiddle($model);
Order::delete($model);
Order::switchModels($model1, $model2);
Order::switchIndexes($model, $index1, $index2);

The model (table) you want to sort needs a sort column. You can specifiy your column in the increment-decrement located in config/increment-decrement.php. Here you can set a

order_column_name

The default order_column_name is obviously order.

Install

You can install the package via composer:

$ composer require larsjanssen6/increment-decrement

This service provider must be installed.

// config/app.php
'providers' => [
    ...
    LarsJanssen\IncrementDecrement\IncrementDecrementServiceProvider::class,
];

This package has a facade. Add it to the aliases array:

// config/app.php
'aliases' => [
    ...
    'Order' => LarsJanssen\IncrementDecrement\OrderFacade::class,
]

You can publish the config-file with:

php artisan vendor:publish --provider="LarsJanssen\IncrementDecrement\IncrementDecrementServiceProvider" --tag="config"

This is the contents of the published config file:

return [
	'order_column_name' => 'order',

	"first_one_can_increment" => true,

	"last_one_can_decrement" => true
];

Usage

First add an integer column to the table (migration) you want to sort. Then migrate again. Specify the column you have added in the config file config/increment-dicrement in order_column_name.

Then you can use the Order facade almost everywhere.

Example:

Make a migration with a column that's going to sort:

public function up()
{
    Schema::create('forum', function (Blueprint $table) {
	    $table->increments('id');
	    $table->string('name');
	    $table->integer('order');
    });
}

Add the column to the config file:

'order_column_name' => 'order',

Then in my ForumController.php:

use Order; 

public function increment(Forum $forum)
{
    Order::increment($forum);
}

.....

The first_one_can_increment and last_one_can_decrement can be set in the config file to determine if the last and first row can increment/decrement.

Do not forget to increment the order column (or what you have specified in the config file) when you create a new record. For example:

return Forum::create([
    'name'          => $request->name,
    'description'   => $request->description,
    'order'         => Forum::all()->max('order') + 1
]);

Result in my own project:

demo

Require

Laravel 5.4 >=

Php 7.0 >=

Testing

You can run the tests with:

vendor/bin/phpunit

Contribute

I would love to hear your ideas to improve my code style and conventions. Feel free to contribute.

License

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

larsjanssen6/increment-decrement 适用场景与选型建议

larsjanssen6/increment-decrement 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「increment」 「Lars Janssen」 「IncreDecre」 「Decrement」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 larsjanssen6/increment-decrement 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 larsjanssen6/increment-decrement 我们能提供哪些服务?
定制开发 / 二次开发

基于 larsjanssen6/increment-decrement 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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