2017 © Pedro Peláez
 

library increment-decrement

Simple ways of incrementing/decrementing and sorting rows

image

larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  • Monday, March 6, 2017
  • by larsjanssen
  • Repository
  • 0 Watchers
  • 5 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Laravel 5.4 sorting rows like a boss

Software License StyleCI Scrutinizer Code Quality Build Status, (*1)

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

Example:, (*3)

demo, (*4)

Once installed you can do the following:, (*5)

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 ```$xslt order_column_name, (*6)


The default ```order_column_name``` is obviously ```order```. # Install You can install the package via composer: ``` bash $ composer require larsjanssen6/increment-decrement

This service provider must be installed., (*7)

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

This package has a facade. Add it to the aliases array:, (*8)

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

You can publish the config-file with:, (*9)

```$xslt php artisan vendor:publish --provider="LarsJanssen\IncrementDecrement\IncrementDecrementServiceProvider" --tag="config", (*10)


This is the contents of the published config file: ```$xslt 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., (*11)

Then you can use the Order facade almost everywhere., (*12)

Example:, (*13)

Make a migration with a column that's going to sort:, (*14)

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


Add the column to the config file: 'order_column_name' => 'order', Then in my ```ForumController.php```:

use Order;, (*16)

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

....., (*18)


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 ]);, (*19)


Result in my own project: ![demo](screenshots/Forum.gif) # Require Laravel 5.4 >= Php 7.0 >= ## Testing You can run the tests with: ```bash vendor/bin/phpunit

Contribute

I would love to hear your ideas to improve my code style and conventions. Feel free to contribute., (*20)

License

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

The Versions

06/03 2017

dev-master

9999999-dev https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

06/03 2017

v1.0.1

1.0.1.0 https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

06/03 2017

v1.2

1.2.0.0 https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

06/03 2017

v2.0

2.0.0.0 https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

06/03 2017

dev-analysis-8LPEow

dev-analysis-8LPEow https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

06/03 2017

dev-implementTrait

dev-implementTrait https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

04/03 2017

v1.1

1.1.0.0 https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

04/03 2017

dev-analysis-8brvMY

dev-analysis-8brvMY https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

04/03 2017

dev-analysis-zdoEyj

dev-analysis-zdoEyj https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

03/03 2017

dev-analysis-87L0aZ

dev-analysis-87L0aZ https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement

03/03 2017

1.0

1.0.0.0 https://github.com/larsjanssen6/increment-decrement

Simple ways of incrementing/decrementing and sorting rows

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

laravel increment lars janssen incredecre decrement