{"id":13684415,"url":"https://github.com/usemuffin/orderly","last_synced_at":"2025-12-28T10:46:12.746Z","repository":{"id":57021791,"uuid":"51081581","full_name":"UseMuffin/Orderly","owner":"UseMuffin","description":"Default ordering for your CakePHP tables","archived":false,"fork":false,"pushed_at":"2024-10-29T09:13:02.000Z","size":34,"stargazers_count":22,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-03T18:07:12.408Z","etag":null,"topics":["cakephp","cakephp-plugin","ordering","php"],"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/UseMuffin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2016-02-04T14:36:30.000Z","updated_at":"2024-10-29T09:12:32.000Z","dependencies_parsed_at":"2022-08-22T20:20:25.586Z","dependency_job_id":"9565cfa8-1b24-4379-bfc0-42e7bbbe0c41","html_url":"https://github.com/UseMuffin/Orderly","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":0.07692307692307687,"last_synced_commit":"a6d7c06f125212a425bb41f196397abb26333b2d"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FOrderly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FOrderly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FOrderly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FOrderly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UseMuffin","download_url":"https://codeload.github.com/UseMuffin/Orderly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251777786,"owners_count":21642225,"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","ordering","php"],"created_at":"2024-08-02T14:00:33.281Z","updated_at":"2025-12-28T10:46:12.700Z","avatar_url":"https://github.com/UseMuffin.png","language":"PHP","readme":"# Orderly\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/UseMuffin/Orderly/ci.yml?style=flat-square\u0026branch=master)](https://github.com/UseMuffin/Orderly/actions/workflows/ci.yml?query=branch%3Amaster)\n[![Coverage](https://img.shields.io/codecov/c/github/UseMuffin/Orderly/master?style=flat-square\n)](https://app.codecov.io/gh/UseMuffin/Orderly)\n[![Total Downloads](https://img.shields.io/packagist/dt/muffin/orderly.svg?style=flat-square)](https://packagist.org/packages/muffin/orderly)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\nAllows setting default order for your tables.\n\n## Install\n\nUsing [Composer][composer]:\n\n```\ncomposer require muffin/orderly\n```\n\nThen load the plugin using the console command:\n\n```\nbin/cake plugin load Muffin/Orderly\n```\n\n## What is does\n\nOrderly allow you to set default `ORDER` clause for your table's `SELECT` queries.\n\n## Usage\n\nHere's how you can add the `Orderly` behavior for your tables:\n\n```php\n// By default orders by display field of table.\n$this-\u003eaddBehavior('Muffin/Orderly.Orderly');\n\n// Default ordering using specified field.\n$this-\u003eaddBehavior('Muffin/Orderly.Orderly', ['order' =\u003e $this-\u003ealiasField('field_name')]);\n```\n\nValue for `order` key can any valid value that `\\Cake\\ORM\\Query::orderBy()` takes.\nThe default order clause will only be applied to the primary query and when no\ncustom order clause has already been set for the query.\n\nYou can also configure the behavior to apply the default order based on required\ncondition using `callback` option. The order will be applied if callback returns `true`:\n\n```php\n$this-\u003eaddBehavior('Muffin/Orderly.Orderly', [\n    'order' =\u003e ['Alias.field_name' =\u003e 'DESC'],\n    'callback' =\u003e function (\\Cake\\ORM\\Query $query, \\ArrayObject $options, bool $primary) {\n        //return a boolean\n    }\n]);\n```\n\nThe behavior can also be configured with multiple orders which are applied based\non return value of their respective callbacks:\n\n```php\n$this-\u003eaddBehavior('Muffin/Orderly.Orderly', [\n    [\n        'order' =\u003e ['Alias.field_name' =\u003e 'DESC'],\n        'callback' =\u003e function (\\Cake\\ORM\\Query $query, \\ArrayObject $options, bool $primary) {\n            //return a boolean\n        }\n    ],\n    [\n        'order' =\u003e ['Alias.another_field'],\n        'callback' =\u003e function (\\Cake\\ORM\\Query $query, \\ArrayObject $options, bool $primary) {\n            //return a boolean\n        }\n    ],\n]);\n```\n\n## Patches \u0026 Features\n\n* Fork\n* Mod, fix\n* Test - this is important, so it's not unintentionally broken\n* Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of\ntheir own that I can ignore when I pull)\n* Pull request - bonus point for topic branches\n\nTo ensure your PRs are considered for upstream, you MUST follow the [CakePHP coding standards][standards].\n\n## Bugs \u0026 Feedback\n\nhttp://github.com/usemuffin/orderly/issues\n\n## License\n\nCopyright (c) 2015-Present, [Use Muffin][muffin] and licensed under [The MIT License][mit].\n\n[cakephp]:http://cakephp.org\n[composer]:http://getcomposer.org\n[mit]:http://www.opensource.org/licenses/mit-license.php\n[muffin]:http://usemuffin.com\n[standards]:http://book.cakephp.org/5/en/contributing/cakephp-coding-conventions.html\n","funding_links":[],"categories":["ORM / Database / Datamapping"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusemuffin%2Forderly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusemuffin%2Forderly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusemuffin%2Forderly/lists"}