Commit 989ba674 authored by Taylor Otwell's avatar Taylor Otwell

Added support for specifying columns when paginating.

parent 8cea0232
......@@ -458,12 +458,26 @@ class Query {
* Get paginated query results.
*
* @param int $per_page
* @param array $columns
* @return Paginator
*/
public function paginate($per_page)
public function paginate($per_page, $columns = array('*'))
{
$select = $this->select;
$total = $this->count();
// Every query clears the SELECT clause, so we store the contents of the clause
// before executing the count query and then put the contents back in afterwards.
if ( ! is_null($select))
{
$this->select = $select;
}
else
{
$this->select($columns);
}
$current_page = \System\Paginator::page($total, $per_page);
return \System\Paginator::make($this->for_page($current_page, $per_page)->get(), $total, $per_page);
......
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