CursorPaginator.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace Illuminate\Contracts\Pagination;
  3. /**
  4. * @template TKey of array-key
  5. *
  6. * @template-covariant TValue
  7. *
  8. * @method $this through(callable(TValue): mixed $callback)
  9. */
  10. interface CursorPaginator
  11. {
  12. /**
  13. * Get the URL for a given cursor.
  14. *
  15. * @param \Illuminate\Pagination\Cursor|null $cursor
  16. * @return string
  17. */
  18. public function url($cursor);
  19. /**
  20. * Add a set of query string values to the paginator.
  21. *
  22. * @param array|string|null $key
  23. * @param string|null $value
  24. * @return $this
  25. */
  26. public function appends($key, $value = null);
  27. /**
  28. * Get / set the URL fragment to be appended to URLs.
  29. *
  30. * @param string|null $fragment
  31. * @return $this|string|null
  32. */
  33. public function fragment($fragment = null);
  34. /**
  35. * Add all current query string values to the paginator.
  36. *
  37. * @return $this
  38. */
  39. public function withQueryString();
  40. /**
  41. * Get the URL for the previous page, or null.
  42. *
  43. * @return string|null
  44. */
  45. public function previousPageUrl();
  46. /**
  47. * The URL for the next page, or null.
  48. *
  49. * @return string|null
  50. */
  51. public function nextPageUrl();
  52. /**
  53. * Get all of the items being paginated.
  54. *
  55. * @return array<TKey, TValue>
  56. */
  57. public function items();
  58. /**
  59. * Get the "cursor" of the previous set of items.
  60. *
  61. * @return \Illuminate\Pagination\Cursor|null
  62. */
  63. public function previousCursor();
  64. /**
  65. * Get the "cursor" of the next set of items.
  66. *
  67. * @return \Illuminate\Pagination\Cursor|null
  68. */
  69. public function nextCursor();
  70. /**
  71. * Determine how many items are being shown per page.
  72. *
  73. * @return int
  74. */
  75. public function perPage();
  76. /**
  77. * Get the current cursor being paginated.
  78. *
  79. * @return \Illuminate\Pagination\Cursor|null
  80. */
  81. public function cursor();
  82. /**
  83. * Determine if there are enough items to split into multiple pages.
  84. *
  85. * @return bool
  86. */
  87. public function hasPages();
  88. /**
  89. * Determine if there are more items in the data source.
  90. *
  91. * @return bool
  92. */
  93. public function hasMorePages();
  94. /**
  95. * Get the base path for paginator generated URLs.
  96. *
  97. * @return string|null
  98. */
  99. public function path();
  100. /**
  101. * Determine if the list of items is empty or not.
  102. *
  103. * @return bool
  104. */
  105. public function isEmpty();
  106. /**
  107. * Determine if the list of items is not empty.
  108. *
  109. * @return bool
  110. */
  111. public function isNotEmpty();
  112. /**
  113. * Render the paginator using a given view.
  114. *
  115. * @param string|null $view
  116. * @param array $data
  117. * @return string
  118. */
  119. public function render($view = null, $data = []);
  120. }