To customize the page, we should tweak the structure of laravel,
We have to access the laravel file
vendor/laravel/framework/src/Illuminate/Pagination/UrlWindow.php
Leave your methods as follows:
public function getStart()
{
return $this->paginator->getUrlRange(1, 1);
}
public function getFinish()
{
return $this->paginator->getUrlRange(
$this->lastPage(),
$this->lastPage()
);
}
public function getAdjacentUrlRange($onEachSide)
{
return $this->paginator->getUrlRange(
$this->currentPage() - 1,
$this->currentPage() + 1
);
}
protected function getSliderTooCloseToEnding($window)
{
$last = $this->paginator->getUrlRange(
$this->lastPage() - (2),
$this->lastPage()
);
return [
'first' => $this->getStart(),
'slider' => null,
'last' => $last,
];
}
protected function getSliderTooCloseToBeginning($window)
{
return [
'first' => $this->paginator->getUrlRange(1, 3),
'slider' => null,
'last' => $this->getFinish(),
];
}
And now the magic is done!