Skip to content

Commit 8b015c4

Browse files
committed
Merge branch 'feature/with-query-string-resolver' of https://github.com/rashidlaasri/framework into rashidlaasri-feature/with-query-string-resolver
2 parents a1b0a99 + 224a11b commit 8b015c4

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/Illuminate/Pagination/AbstractPaginator.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ abstract class AbstractPaginator implements Htmlable
100100
*/
101101
protected static $viewFactoryResolver;
102102

103+
/**
104+
* The with query string resolver callback.
105+
*
106+
* @var \Closure
107+
*/
108+
protected static $queryStringResolver;
109+
103110
/**
104111
* The default pagination view.
105112
*
@@ -215,6 +222,20 @@ public function appends($key, $value = null)
215222
return $this->addQuery($key, $value);
216223
}
217224

225+
/**
226+
* Add all 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+
218239
/**
219240
* Add an array of query string values.
220241
*
@@ -484,6 +505,17 @@ public static function viewFactoryResolver(Closure $resolver)
484505
static::$viewFactoryResolver = $resolver;
485506
}
486507

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+
487519
/**
488520
* Set the default pagination view.
489521
*

src/Illuminate/Pagination/PaginationServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ public function register()
4646

4747
return 1;
4848
});
49+
50+
Paginator::withQueryStringResolver(function () {
51+
return $this->app['request']->query();
52+
});
4953
}
5054
}

0 commit comments

Comments
 (0)