Skip to content

Commit

Permalink
Update AbstractRepository.php
Browse files Browse the repository at this point in the history
Add limit and more pagination arguments
  • Loading branch information
Torann authored Sep 11, 2017
1 parent 5e43ec7 commit 5945993
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/Repositories/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,20 @@ public function search($queries)
});
}

/**
* Set the "limit" value of the query.
*
* @param int $limit
*
* @return self
*/
public function limit($limit)
{
return $this->addScopeQuery(function ($query) use ($limit) {
return $query->limit($limit);
});
}

/**
* Retrieve all data of repository
*
Expand Down Expand Up @@ -399,31 +413,33 @@ public function pluck($value, $key = null)
/**
* Retrieve all data of repository, paginated
*
* @param null $limit
* @param array $columns
* @param int $limit
* @param array $columns
* @param int|null $page
*
* @return \Illuminate\Pagination\Paginator
*/
public function paginate($limit = null, $columns = ['*'])
public function paginate($limit = null, $columns = ['*'], $page = null)
{
$this->newQuery();

return $this->query->paginate($limit, $columns);
return $this->query->paginate($limit, $columns, $page);
}

/**
* Retrieve all data of repository, paginated
*
* @param null $limit
* @param array $columns
* @param int $limit
* @param array $columns
* @param int|null $page
*
* @return \Illuminate\Pagination\Paginator
*/
public function simplePaginate($limit = null, $columns = ['*'])
public function simplePaginate($limit = null, $columns = ['*'], $page = null)
{
$this->newQuery();

return $this->query->simplePaginate($limit, $columns);
return $this->query->simplePaginate($limit, $columns, $page);
}

/**
Expand Down Expand Up @@ -648,4 +664,4 @@ public function __call($method, $parameters)

throw new BadMethodCallException("Call to undefined method {$className}::{$method}()");
}
}
}

0 comments on commit 5945993

Please sign in to comment.