Skip to content

Commit

Permalink
Merge pull request #123 from damiantw/master
Browse files Browse the repository at this point in the history
Add orderBy support to Builder
  • Loading branch information
taylorotwell authored Nov 7, 2016
2 parents b6c3107 + a5b7cdd commit 1a320db
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class Builder
*/
public $limit;

/**
* The "order" that should be applied to the search.
*
* @var int
*/
public $orders = [];

/**
* Create a new search builder instance.
*
Expand Down Expand Up @@ -105,6 +112,23 @@ public function take($limit)
return $this;
}

/**
* Add an "order" for the search query.
*
* @param string $column
* @param string $direction
* @return $this
*/
public function orderBy($column, $direction = 'asc')
{
$this->orders[] = [
'column' => $column,
'direction' => strtolower($direction) == 'asc' ? 'asc' : 'desc',
];

return $this;
}

/**
* Get the first result from the search.
*
Expand Down

0 comments on commit 1a320db

Please sign in to comment.