|
3 | 3 | namespace Illuminate\Pagination;
|
4 | 4 |
|
5 | 5 | use Closure;
|
6 |
| -use Illuminate\Contracts\Support\Htmlable; |
7 | 6 | use Illuminate\Support\Arr;
|
8 |
| -use Illuminate\Support\Collection; |
9 | 7 | use Illuminate\Support\Str;
|
| 8 | +use Illuminate\Support\Collection; |
| 9 | +use Illuminate\Contracts\Support\Htmlable; |
10 | 10 | use Illuminate\Support\Traits\ForwardsCalls;
|
11 | 11 |
|
12 | 12 | /**
|
@@ -100,6 +100,13 @@ abstract class AbstractPaginator implements Htmlable
|
100 | 100 | */
|
101 | 101 | protected static $viewFactoryResolver;
|
102 | 102 |
|
| 103 | + /** |
| 104 | + * The with query string resolver callback. |
| 105 | + * |
| 106 | + * @var \Closure |
| 107 | + */ |
| 108 | + protected static $queryStringResolver; |
| 109 | + |
103 | 110 | /**
|
104 | 111 | * The default pagination view.
|
105 | 112 | *
|
@@ -215,6 +222,20 @@ public function appends($key, $value = null)
|
215 | 222 | return $this->addQuery($key, $value);
|
216 | 223 | }
|
217 | 224 |
|
| 225 | + /** |
| 226 | + * Add a set of query string values to the paginator. |
| 227 | + * |
| 228 | + * @return $this |
| 229 | + */ |
| 230 | + public function withQueryString() |
| 231 | + { |
| 232 | + if (isset(static::$queryStringResolver)) { |
| 233 | + return $this->appends(call_user_func(static::$queryStringResolver)); |
| 234 | + } |
| 235 | + |
| 236 | + return $this; |
| 237 | + } |
| 238 | + |
218 | 239 | /**
|
219 | 240 | * Add an array of query string values.
|
220 | 241 | *
|
@@ -484,6 +505,17 @@ public static function viewFactoryResolver(Closure $resolver)
|
484 | 505 | static::$viewFactoryResolver = $resolver;
|
485 | 506 | }
|
486 | 507 |
|
| 508 | + /** |
| 509 | + * Set with query string resolver callback. |
| 510 | + * |
| 511 | + * @param \Closure $resolver |
| 512 | + * @return void |
| 513 | + */ |
| 514 | + public static function withQueryStringResolver(Closure $resolver) |
| 515 | + { |
| 516 | + static::$queryStringResolver = $resolver; |
| 517 | + } |
| 518 | + |
487 | 519 | /**
|
488 | 520 | * Set the default pagination view.
|
489 | 521 | *
|
|
0 commit comments