{"id":15529153,"url":"https://github.com/admad/cakephp-sequence","last_synced_at":"2025-04-13T07:51:24.020Z","repository":{"id":27245627,"uuid":"30717712","full_name":"ADmad/cakephp-sequence","owner":"ADmad","description":"CakePHP plugin for maintaining a contiguous sequence of records","archived":false,"fork":false,"pushed_at":"2024-12-21T12:33:21.000Z","size":106,"stargazers_count":44,"open_issues_count":0,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T05:45:56.765Z","etag":null,"topics":["cakephp","cakephp-plugin","php","sequence","sorting"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ADmad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ADmad"]}},"created_at":"2015-02-12T18:45:01.000Z","updated_at":"2024-12-21T12:33:24.000Z","dependencies_parsed_at":"2024-04-10T05:38:39.328Z","dependency_job_id":"b16dc600-5844-4c71-b060-2e87f9a8ca52","html_url":"https://github.com/ADmad/cakephp-sequence","commit_stats":{"total_commits":94,"total_committers":10,"mean_commits":9.4,"dds":"0.23404255319148937","last_synced_commit":"6f3407703162ea0627e337682a2c68cc024a5602"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADmad%2Fcakephp-sequence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADmad%2Fcakephp-sequence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADmad%2Fcakephp-sequence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ADmad%2Fcakephp-sequence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ADmad","download_url":"https://codeload.github.com/ADmad/cakephp-sequence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","cakephp-plugin","php","sequence","sorting"],"created_at":"2024-10-02T11:16:40.415Z","updated_at":"2025-04-13T07:51:23.996Z","avatar_url":"https://github.com/ADmad.png","language":"PHP","readme":"# Sequence plugin to maintain ordered list of records\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/ADmad/cakephp-sequence/ci.yml?branch=master\u0026style=flat-square)](https://github.com/ADmad/cakephp-sequence/actions/workflows/ci.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/ADmad/cakephp-sequence.svg?style=flat-square)](https://codecov.io/github/ADmad/cakephp-sequence)\n[![Total Downloads](https://img.shields.io/packagist/dt/admad/cakephp-sequence.svg?style=flat-square)](https://packagist.org/packages/admad/cakephp-sequence)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt)\n\n## Installation\n\nInstall this plugin into your CakePHP application using [composer](http://getcomposer.org):\n\n```\ncomposer require admad/cakephp-sequence\n```\n\nThen load the plugin by running CLI command:\n\n```bash\n./bin/cake plugin load ADmad/Sequence\n```\n\n## How it works\n\n`SequenceBehavior` provided by this plugin maintains a contiguous sequence of\nintegers in a selected column, for records in a table (optionally with grouping)\nwhen adding, editing (including moving groups) or deleting records.\n\n## Usage\n\nAdd the `SequenceBehavior` for your table and viola:\n\n```php\n$this-\u003eaddBehavior('ADmad/Sequence.Sequence');\n```\n\nYou can customize various options as shown:\n\n```php\n$this-\u003eaddBehavior('ADmad/Sequence.Sequence', [\n    'sequenceField' =\u003e 'position', // Field to use to store integer sequence. Default \"position\".\n    'scope' =\u003e ['group_id'], // Array of field names to use for grouping records. Default [].\n    'startAt' =\u003e 1, // Initial value for sequence. Default 1.\n]);\n```\n\nNow whenever a new record is added its `position` field will be automatically\nset to current largest value in sequence plus one.\n\nWhen editing records you can set the position to a new value and the position of\nother records in the list will be automatically updated to maintain proper\nsequence.\n\nWhen doing a find on the table an order clause is automatically added to the\nquery to order by the position field if an order clause has not already been set.\n\n### Methods\n\n#### moveUp(\\Cake\\Datasource\\EntityInterface $entity)\nMove up record by one position:\n\n```php\n$modelObject-\u003emoveUp($entity);\n```\n\n#### moveDown(\\Cake\\Datasource\\EntityInterface $entity)\nMove down record by one position:\n\n```php\n$modelObject-\u003emoveDown($entity);\n```\n\n#### setOrder(array $record)\nSet order for list of records provided. Records can be provided as array of\nentities or array of associative arrays like `[['id' =\u003e 1], ['id' =\u003e 2]]` or\narray of primary key values like `[1, 2]`.\n\n## Acknowledgement\n\nShout out to @neilcrookes for his wonderful Sequence Behavior for CakePHP 1.3\nwhich was the inspiration for this plugin.\n","funding_links":["https://github.com/sponsors/ADmad"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmad%2Fcakephp-sequence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadmad%2Fcakephp-sequence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmad%2Fcakephp-sequence/lists"}