forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Add cursor pagination (aka keyset pagination) (laravel#37216)
* Add cursor pagination without tests * Fix styleci * Add cursor paginator tests * Add support for query builder * Fix tests * Complete all tests for database and Eloquent builders * Incorporate suggestions * Fix styleci * Fix docblocks * move method * Fix docblock * Formatting * Various formatting - method renaming. * Add more tests Co-authored-by: Taylor Otwell <taylorotwell@gmail.com>
- Loading branch information
1 parent
8c57f17
commit b85e127
Showing
19 changed files
with
1,845 additions
and
2 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
src/Illuminate/Contracts/Pagination/CursorPaginator.php
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,117 @@ | ||
<?php | ||
|
||
namespace Illuminate\Contracts\Pagination; | ||
|
||
interface CursorPaginator | ||
{ | ||
/** | ||
* Get the URL for a given cursor. | ||
* | ||
* @param \Illuminate\Pagination\Cursor|null $cursor | ||
* @return string | ||
*/ | ||
public function url($cursor); | ||
|
||
/** | ||
* Add a set of query string values to the paginator. | ||
* | ||
* @param array|string|null $key | ||
* @param string|null $value | ||
* @return $this | ||
*/ | ||
public function appends($key, $value = null); | ||
|
||
/** | ||
* Get / set the URL fragment to be appended to URLs. | ||
* | ||
* @param string|null $fragment | ||
* @return $this|string|null | ||
*/ | ||
public function fragment($fragment = null); | ||
|
||
/** | ||
* Get the URL for the previous page, or null. | ||
* | ||
* @return string|null | ||
*/ | ||
public function previousPageUrl(); | ||
|
||
/** | ||
* The URL for the next page, or null. | ||
* | ||
* @return string|null | ||
*/ | ||
public function nextPageUrl(); | ||
|
||
/** | ||
* Get all of the items being paginated. | ||
* | ||
* @return array | ||
*/ | ||
public function items(); | ||
|
||
/** | ||
* Get the "cursor" of the previous set of items. | ||
* | ||
* @return \Illuminate\Pagination\Cursor|null | ||
*/ | ||
public function previousCursor(); | ||
|
||
/** | ||
* Get the "cursor" of the next set of items. | ||
* | ||
* @return \Illuminate\Pagination\Cursor|null | ||
*/ | ||
public function nextCursor(); | ||
|
||
/** | ||
* Determine how many items are being shown per page. | ||
* | ||
* @return int | ||
*/ | ||
public function perPage(); | ||
|
||
/** | ||
* Get the current cursor being paginated. | ||
* | ||
* @return \Illuminate\Pagination\Cursor|null | ||
*/ | ||
public function cursor(); | ||
|
||
/** | ||
* Determine if there are enough items to split into multiple pages. | ||
* | ||
* @return bool | ||
*/ | ||
public function hasPages(); | ||
|
||
/** | ||
* Get the base path for paginator generated URLs. | ||
* | ||
* @return string|null | ||
*/ | ||
public function path(); | ||
|
||
/** | ||
* Determine if the list of items is empty or not. | ||
* | ||
* @return bool | ||
*/ | ||
public function isEmpty(); | ||
|
||
/** | ||
* Determine if the list of items is not empty. | ||
* | ||
* @return bool | ||
*/ | ||
public function isNotEmpty(); | ||
|
||
/** | ||
* Render the paginator using a given view. | ||
* | ||
* @param string|null $view | ||
* @param array $data | ||
* @return string | ||
*/ | ||
public function render($view = null, $data = []); | ||
} |
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
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
Oops, something went wrong.