2017 © Pedro Peláez
 

library cahen

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.

image

sukohi/cahen

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.

  • Monday, January 30, 2017
  • by Sukohi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,707 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 12 % Grown

The README.md

Cahen

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.
(This is for Laravel 5+. For Laravel 4.2), (*1)

Installation

Add this package name in composer.json, (*2)

"require": {
  "sukohi/cahen": "2.*"
}

Execute composer command., (*3)

composer update

Register the service provider in app.php, (*4)

'providers' => [
    ...Others...,  
    Sukohi\Cahen\CahenServiceProvider::class,
]

Also alias, (*5)

'aliases' => [
    ...Others...,  
    'Cahen'   => Sukohi\Cahen\Facades\Cahen::class
]

Usage

Basic, (*6)

$model = YourModel::find(1);
\Cahen::move($model)->to('your-column-name', 5);

Up, (*7)

\Cahen::move($model)->up('your-column-name');

Down, (*8)

\Cahen::move($model)->down('your-column-name');

to First, (*9)

\Cahen::move($model)->first('your-column-name');

to Last, (*10)

\Cahen::move($model)->last('your-column-name');

with Transaction, (*11)

\DB::beginTransaction();

if(!\Cahen::move($model)->to('your-column-name', 5)) {

    \DB::rollback();

}

\DB::commit();

with Where Clause, (*12)

You can use where clause to sort within specific record(s)., (*13)

$model = YourModel::find(1);
\Cahen::move($model)
        ->where('column_1', '=', 'value')
        ->where('column_2', 'LIKE', '%value%')
        ->to('your-column-name', 5);

Set data, (*14)

You can sort within specific record(s) by setting model object., (*15)

$moving_id = 1;
$model = YourModel::find($moving_id);
$models = YourModel::where('id', '<', 5)
            ->where('id', '<>', $moving_id)
            ->get();
\Cahen::move($model)
        ->data($models)
        ->to('your-column-name', 3);
  • Note: You can not include a record that has ID is $moving_id in $models.

Alignment, (*16)

$model = YourModel::orderBy('id', 'ASC')->get();
\Cahen::align($model, 'your-column-name');

About Sort Number, (*17)

The sort value starts from 0., (*18)

License

This package is licensed under the MIT License., (*19)

Copyright 2014 Sukohi Kuhoh, (*20)

The Versions

30/01 2017

2.0.x-dev

2.0.9999999.9999999-dev

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

30/01 2017

dev-master

9999999-dev

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

30/01 2017

2.0.1

2.0.1.0

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

19/08 2015

1.0.x-dev

1.0.9999999.9999999-dev

A PHP package mainly developed for Laravel to manage order numbers of DB.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

19/08 2015

1.0.1

1.0.1.0

A PHP package mainly developed for Laravel to manage order numbers of DB.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

12/08 2015

2.0.0

2.0.0.0

A PHP package mainly developed for Laravel to manage sort values of DB table automatically.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

12/08 2015

1.0.0

1.0.0.0

A PHP package mainly developed for Laravel to manage order numbers of DB.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi