Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
//Definindo a ordenação da paginação por dois itens
/**
*
* @param array $queryData
* @return array
*/
public function beforeFind( $queryData )
{
parent::beforeFind($queryData);
if ( !empty($queryData['sort']) && $queryData['sort'] == 'primeiro_campo' ) {
$segundoCampo = array($this->alias . '.segundo_campo' => '[ASC|DESC]');
if (is_array($queryData['order'][0])) {
$queryData['order'][0] = $queryData['order'][0] + $segundoCampo;
} else {
$queryData['order'][0] = $segundoCampo;
}
}
return $queryData;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment