All Projects → UseMuffin → Orderly

UseMuffin / Orderly

Licence: MIT license
Default ordering for your CakePHP tables

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Orderly

Cakephp Csvview
CakePHP: A view class for generating CSV
Stars: ✭ 174 (+728.57%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-swagger-bake
Automatically generate OpenAPI, Swagger, and Redoc documentation from your existing CakePHP code.
Stars: ✭ 48 (+128.57%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Proffer
An upload plugin for CakePHP 3
Stars: ✭ 121 (+476.19%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-ajax
AJAX for CakePHP: A plugin to ease handling AJAX requests.
Stars: ✭ 55 (+161.9%)
Mutual labels:  cakephp, cakephp-plugin
plum search
Plum Search plugin for CakePHP
Stars: ✭ 20 (-4.76%)
Mutual labels:  cakephp, cakephp-plugin
Migrations
CakePHP database migrations plugin
Stars: ✭ 114 (+442.86%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Imagine Plugin
CakePHP wrapper for the powerful Imagine image processing library. Makes images manipulation easy and powerful.
Stars: ✭ 140 (+566.67%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Hybridauth
CakePHP plugin for HybridAuth
Stars: ✭ 81 (+285.71%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-i18n
A CakePHP plugin with I18n related tools.
Stars: ✭ 40 (+90.48%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Jwt Auth
A CakePHP plugin for authenticating using JSON Web Tokens
Stars: ✭ 153 (+628.57%)
Mutual labels:  cakephp, cakephp-plugin
auth
Auth objects for CakePHP
Stars: ✭ 28 (+33.33%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-error-email
ErrorEmail Plugin for CakePHP3.x
Stars: ✭ 16 (-23.81%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Tinyauth
CakePHP TinyAuth plugin for an easy and fast user authentication and authorization. Single or multi role. DB or config file based.
Stars: ✭ 114 (+442.86%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-shim
CakePHP plugin to "shim" functionality up and down for major versions of the framework.
Stars: ✭ 37 (+76.19%)
Mutual labels:  cakephp, cakephp-plugin
Acl
Plugin for managing ACL in CakePHP applications.
Stars: ✭ 113 (+438.1%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Ide Helper
IDE Helper plugin for CakePHP
Stars: ✭ 138 (+557.14%)
Mutual labels:  cakephp, cakephp-plugin
Webservice
Bringing the power of the CakePHP ORM to your favourite webservices
Stars: ✭ 79 (+276.19%)
Mutual labels:  cakephp, cakephp-plugin
Footprint
CakePHP plugin to allow passing currently logged in user to model layer.
Stars: ✭ 81 (+285.71%)
Mutual labels:  cakephp, cakephp-plugin
Search
CakePHP: Easy model searching
Stars: ✭ 153 (+628.57%)
Mutual labels:  cakephp, cakephp-plugin
elastic-search
Elastic search datasource for CakePHP
Stars: ✭ 85 (+304.76%)
Mutual labels:  cakephp, cakephp-plugin

Orderly

Build Status Coverage Total Downloads License

Allows setting default order for your tables.

Install

Using Composer:

composer require muffin/orderly

Then load the plugin using the console command:

bin/cake plugin load Muffin/Orderly

What is does

Orderly allow you to set default ORDER clause for your table queries, similar to the functionality provided by Model::$order property of CakePHP 2.x.

Usage

Here's how you can add the Orderly behavior for your tables:

// By default orders by display field of table.
$this->addBehavior('Muffin/Orderly.Orderly');

// Default ordering using specified field.
$this->addBehavior('Muffin/Orderly.Orderly', ['order' => $this->aliasField('field_name')]);

Value for order key can any valid value that \Cake\ORM\Query::order() takes. The default order clause will only be applied to the primary query and when no custom order clause has already been set for the query.

You can also configure the behavior to apply the default order based on required condition using callback option. The order will be applied if callback returns true:

$this->addBehavior('Muffin/Orderly.Orderly', [
    'order' => ['Alias.field_name' => 'DESC'],
    'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
        //return a boolean
    }
]);

The behavior can also be configured with multiple orders which are applied based on return value of their respective callbacks:

$this->addBehavior('Muffin/Orderly.Orderly', [
    [
        'order' => ['Alias.field_name' => 'DESC'],
        'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
            //return a boolean
        }
    ],
    [
        'order' => ['Alias.another_field'],
        'callback' => function (\Cake\ORM\Query $query, \ArrayObject $options, bool $primary) {
            //return a boolean
        }
    ],
]);

Patches & Features

  • Fork
  • Mod, fix
  • Test - this is important, so it's not unintentionally broken
  • Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of their own that I can ignore when I pull)
  • Pull request - bonus point for topic branches

To ensure your PRs are considered for upstream, you MUST follow the CakePHP coding standards.

Bugs & Feedback

http://github.com/usemuffin/orderly/issues

License

Copyright (c) 2015-Present, Use Muffin and licensed under The MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].