Level 51
@bajki Did you see there is an answer here for extending? ... it's almost the same code as Laravel 8 https://stackoverflow.com/questions/42776102/how-to-remove-query-string-page-from-the-first-page-of-laravel-pagination
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, i would like to remove page=1 from query.
Is there any way to overide url() function in AbstractPaginator
/**
* Get the URL for a given page number.
*
* @param int $page
* @return string
*/
public function url($page)
{
if ($page <= 0) {
$page = 1;
}
// If we have any extra query string key / value pairs that need to be added
// onto the URL, we will put them in query string form and then attach it
// to the URL. This allows for extra information like sortings storage.
$parameters = [$this->pageName => $page];
if (count($this->query) > 0) {
$parameters = array_merge($this->query, $parameters);
}
return $this->path()
.(Str::contains($this->path(), '?') ? '&' : '?')
.Arr::query($parameters)
.$this->buildFragment();
}
with if ($page <= 1) { return $this->path(); }
Thanks.
Please or to participate in this conversation.