|
7 | 7 |
|
8 | 8 | ## Installation |
9 | 9 |
|
10 | | -You can install this plugin into your CakePHP application using [composer](http://getcomposer.org). |
11 | | - |
12 | | -The recommended way to install composer packages is: |
| 10 | +Install this plugin into your CakePHP application using [composer](http://getcomposer.org): |
13 | 11 |
|
14 | 12 | ``` |
15 | 13 | composer require admad/cakephp-sequence |
16 | 14 | ``` |
17 | 15 |
|
18 | | -Then load the plugin by adding the following to your app's config/boostrap.php: |
| 16 | +Then load the plugin by either running: |
19 | 17 |
|
20 | | -```php |
21 | | -\Cake\Core\Plugin::load('ADmad/Sequence'); |
| 18 | +```bash |
| 19 | +./bin/cake plugin load ADmad/Sequence |
22 | 20 | ``` |
23 | 21 |
|
24 | | -or using CakePHP's console: |
| 22 | +or adding the following line to `config/bootstrap.php`: |
25 | 23 |
|
26 | | -``` |
27 | | -./bin/cake plugin load ADmad/Sequence |
| 24 | +```php |
| 25 | +\Cake\Core\Plugin::load('ADmad/Sequence'); |
28 | 26 | ``` |
29 | 27 |
|
30 | 28 | ## How it works |
31 | 29 |
|
32 | | -`SequenceBehavior` provided by this plugin maintains a contiguous sequence of |
33 | | -integers in a selected column, for records in a table records (optionally with grouping) |
| 30 | +`SequenceBehavior` provided by this plugin maintains a contiguous sequence of |
| 31 | +integers in a selected column, for records in a table records (optionally with grouping) |
34 | 32 | when adding, editing (including moving groups) or deleting records. |
35 | 33 |
|
36 | 34 | ## Usage |
37 | 35 |
|
38 | 36 | Add the `SequenceBehavior` for your table and viola: |
39 | 37 |
|
40 | 38 | ```php |
41 | | -$this->addBehavior('ADmad/Sequence'); |
| 39 | +$this->addBehavior('ADmad/Sequence.Sequence'); |
42 | 40 | ``` |
43 | 41 |
|
44 | 42 | You can customize various options as shown: |
45 | 43 |
|
46 | 44 | ```php |
47 | | -$this->addBehavior('ADmad/Sequence', [ |
| 45 | +$this->addBehavior('ADmad/Sequence.Sequence', [ |
48 | 46 | 'order' => 'position', // Field to use to store integer sequence. Default "position". |
49 | 47 | 'scope' => ['group_id'], // Array of field names to use for grouping records. Default []. |
50 | 48 | 'start' => 1, // Initial value for sequence. Default 1. |
|
0 commit comments