-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
103 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php namespace October\Rain\Database\Concerns; | ||
|
||
/** | ||
* HasNicerPagination for a query builder | ||
*/ | ||
trait HasNicerPagination | ||
{ | ||
/** | ||
* paginateAtPage paginates by passing the page number directly | ||
* | ||
* @param int $perPage | ||
* @param int $currentPage | ||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator | ||
*/ | ||
public function paginateAtPage($perPage, $currentPage) | ||
{ | ||
return $this->paginate($perPage, ['*'], 'page', $currentPage); | ||
} | ||
|
||
/** | ||
* paginateCustom paginates using a custom page name. | ||
* | ||
* @param int $perPage | ||
* @param string $pageName | ||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator | ||
*/ | ||
public function paginateCustom($perPage, $pageName) | ||
{ | ||
return $this->paginate($perPage, ['*'], $pageName); | ||
} | ||
|
||
/** | ||
* simplePaginateAtPage simply paginates by passing the page number directly | ||
* | ||
* @param int $perPage | ||
* @param int $currentPage | ||
* @return \Illuminate\Contracts\Pagination\Paginator | ||
*/ | ||
public function simplePaginateAtPage($perPage, $currentPage) | ||
{ | ||
return $this->simplePaginate($perPage, ['*'], 'page', $currentPage); | ||
} | ||
|
||
/** | ||
* simplePaginateCustom simply paginates using a custom page name. | ||
* | ||
* @param int $perPage | ||
* @param string $pageName | ||
* @return \Illuminate\Contracts\Pagination\Paginator | ||
*/ | ||
public function simplePaginateCustom($perPage, $pageName) | ||
{ | ||
return $this->simplePaginate($perPage, ['*'], $pageName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters