Closed jaiselrahman closed 5 years ago
I decided to leave that to Laravel's AbstractPaginator
since it already takes care of it, but I guess I forgot to delete some code in CursorPaginator
's constructor which might've led to some confusion.
If you want to to change the path, call the setPath()
method on the paginator instance:
return Post::orderBy('id')
->cursorPaginate()
->setPath(url('/somewhere'));
To have a default path, just register a path resolver in your AppServiceProvider.php for example:
use Amrnn\CursorPaginator\CursorPaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
CursorPaginator::currentPathResolver(function () {
return url('/default-path');
});
}
}
Yes got confused by this line https://github.com/amrnn90/laravel-cursor-paginator/blob/294f340c79b14af72d85b9f3e17ef9579c5774f1/src/CursorPaginator.php#L31-L33 Now I got it, Thanks, I am closing this issue now.
It seems that
$this->options
value is not passed toCursorPaginator
, which makes it unable to change the path in navigation url.https://github.com/amrnn90/laravel-cursor-paginator/blob/294f340c79b14af72d85b9f3e17ef9579c5774f1/src/Macro.php#L12-L25
And also it would be great to customise the default path in config file.