1- # Sequence plugin for CakePHP 3.0+ to maintain ordered list of records
1+ # Sequence plugin to maintain ordered list of records
22
33[ ![ Build Status] ( https://img.shields.io/travis/ADmad/cakephp-sequence/master.svg?style=flat-square )] ( https://travis-ci.org/ADmad/cakephp-sequence )
44[ ![ Coverage] ( https://img.shields.io/coveralls/ADmad/cakephp-sequence/master.svg?style=flat-square )] ( https://coveralls.io/r/ADmad/cakephp-sequence )
@@ -15,9 +15,37 @@ The recommended way to install composer packages is:
1515composer require admad/cakephp-sequence
1616```
1717
18- ## Todo
18+ Then load the plugin by adding the following to your app's config/boostrap.php:
1919
20- - Improve this README : P
20+ \Cake\Core\Plugin::load('ADmad/Sequence');
21+
22+ or using CakePHP's console:
23+
24+ ./bin/cake plugin load ADmad/Sequence
25+
26+ ## How it works
27+
28+ ` SequenceBehavior ` provided by this plugin maintains a contiguous sequence of
29+ integers in a selected column, for records in a table records (optionally with grouping)
30+ when adding, editing (including moving groups) or deleting records.
31+
32+ ## Usage
33+
34+ Add the ` SequenceBehavior ` for your table and viola:
35+
36+ ``` php
37+ $this->addBehavior('ADmad/Sequence');
38+ ```
39+
40+ You can customize various options as shown:
41+
42+ ``` php
43+ $this->addBehavior('ADmad/Sequence', [
44+ 'order' => 'position', // Field to use to store integer sequence. Default "position".
45+ 'scope' => ['group_id'], // Array of field names to use for grouping records. Default [].
46+ 'start' => 1, // Initial value for sequence. Default 1.
47+ ]);
48+ ```
2149
2250## Acknowledgement
2351
0 commit comments