Commit d15e1e16 authored by khamkham's avatar khamkham

Add natural reverse (descending) sort option

parent 93b7afd5
......@@ -281,17 +281,17 @@ class Builder extends \Illuminate\Database\Query\Builder {
* @param string $direction
* @return Builder
*/
public function orderBy($column, $direction = null)
public function orderBy($column, $direction = 'asc')
{
if (is_null($direction) && $column == 'natural')
$direction = (strtolower($direction) == 'asc' ? 1 : -1);
if ($column == 'natural')
{
$this->orders['$natural'] = 1;
$this->orders['$natural'] = $direction;
}
else
{
$direction = $direction ?: 'asc';
$this->orders[$column] = (strtolower($direction) == 'asc' ? 1 : -1);
$this->orders[$column] = $direction;
}
return $this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment