2017 © Pedro Peláez
 

cakephp-plugin cakephp-sequence

Sequence plugin for CakePHP to maintain ordered list of records

image

admad/cakephp-sequence

Sequence plugin for CakePHP to maintain ordered list of records

  • Monday, May 14, 2018
  • by ADmad
  • Repository
  • 6 Watchers
  • 27 Stars
  • 39,678 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 12 Versions
  • 12 % Grown

The README.md

Sequence plugin to maintain ordered list of records

Build Status Coverage Total Downloads License, (*1)

Installation

Install this plugin into your CakePHP application using composer:, (*2)

composer require admad/cakephp-sequence

Then load the plugin by running CLI command:, (*3)

./bin/cake plugin load ADmad/Sequence

How it works

SequenceBehavior provided by this plugin maintains a contiguous sequence of integers in a selected column, for records in a table (optionally with grouping) when adding, editing (including moving groups) or deleting records., (*4)

Usage

Add the SequenceBehavior for your table and viola:, (*5)

$this->addBehavior('ADmad/Sequence.Sequence');

You can customize various options as shown:, (*6)

$this->addBehavior('ADmad/Sequence.Sequence', [
    'sequenceField' => 'position', // Field to use to store integer sequence. Default "position".
    'scope' => ['group_id'], // Array of field names to use for grouping records. Default [].
    'startAt' => 1, // Initial value for sequence. Default 1.
]);

Now whenever a new record is added its position field will be automatically set to current largest value in sequence plus one., (*7)

When editing records you can set the position to a new value and the position of other records in the list will be automatically updated to maintain proper sequence., (*8)

When doing a find on the table an order clause is automatically added to the query to order by the position field if an order clause has not already been set., (*9)

Methods

moveUp(\Cake\Datasource\EntityInterface $entity)

Move up record by one position:, (*10)

$modelObject->moveUp($entity);

moveDown(\Cake\Datasource\EntityInterface $entity)

Move down record by one position:, (*11)

$modelObject->moveDown($entity);

setOrder(array $record)

Set order for list of records provided. Records can be provided as array of entities or array of associative arrays like [['id' => 1], ['id' => 2]] or array of primary key values like [1, 2]., (*12)

Acknowledgement

Shout out to @neilcrookes for his wonderful Sequence Behavior for CakePHP 1.3 which was the inspiration for this plugin., (*13)

The Versions

14/05 2018

dev-master

9999999-dev

Sequence plugin for CakePHP to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

14/05 2018

2.2.1

2.2.1.0

Sequence plugin for CakePHP to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

18/04 2018

2.2.0

2.2.0.0

Sequence plugin for CakePHP to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

18/04 2018

dev-cake-update

dev-cake-update

Sequence plugin for CakePHP to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

02/08 2017

2.1.0

2.1.0.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

11/04 2017

2.0.3

2.0.3.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

01/06 2016

dev-analysis-z4wpwk

dev-analysis-z4wpwk

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

01/06 2016

2.0.2

2.0.2.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

14/05 2016

2.0.1

2.0.1.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

05/02 2016

2.0.0

2.0.0.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

The Development Requires

orm cakephp list sequence

23/12 2015

1.0.1

1.0.1.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires

 

01/12 2015

1.0.0

1.0.0.0

Sequence plugin for CakePHP 3.0+ to maintain ordered list of records

  Sources   Download

MIT

The Requires