Автор оригинала: David Wong.
1. Настройте класс (код выглядит следующим образом), разместите его так, как вам нравится, и обратите внимание на пространство имен. 2. Вызов вывода шаблона {!! $данные – > визуализация (Новое \ приложение \ http \ контроллеры \ shmilythreepresenter ($данные))!} Окончательный стиль
_
php //Create and inherit from the illuminate \ pagination \ bootstrapthreepresenter class. Here I put the class under controllers. You need to modify the methods of the bootstrapthreepresenter class to override the methods. If you feel that the default bootstrap style does not match the style of your project, you can customize the style. namespace App\Http\Controllers; use Illuminate\Contracts\Pagination\Paginator as PaginatorContract; use Illuminate\Contracts\Pagination\Presenter as PresenterContract; class ShmilyThreePresenter extends \Illuminate\Pagination\BootstrapThreePresenter { /** * Convert the URL window into Bootstrap HTML. * * @return string */ public function render() { if ($this->hasPages()) { return sprintf( '< UL class = "am paging" >% s% s% s% s < / UL >', // custom class style $this - > firstpage(), // add homepage method $this - > getpreviousbutton ('previous'), $this->getLinks(), $this - > getnextbutton ('next page '), $this - > last() // add end page method ); } return ''; } /** * Get HTML wrapper for an available page link. * * @param string $url * @param int $page * @param string|null $rel * @return string */ protected function getAvailablePageWrapper($url, $page, $rel = null) { $rel = is_null($rel) ? '' : ' rel="'.$rel.'"'; return ''.$page.' '; //Here Li tag can add your own class style } /** * Get HTML wrapper for disabled text. * * @param string $text * @return string */ protected function getDisabledTextWrapper($text) { return ''.$text.' '; } /** * Get HTML wrapper for active text. * * @param string $text * @return string */ protected function getActivePageWrapper($text) { return ''.$text.' '; } /** * Get the next page pagination element. * * @param string $text * @return string */ //New homepage method Public function firstpage ($text = 'first page') { // If the current page is greater than or equal to the last page, it means we // can't go any further into the pages, as we're already on this last page // that is available, so we will make it the "next" link style disabled. if ($this->paginator->currentPage() <= 1) { return $this->getDisabledTextWrapper($text); } $url = $this->paginator->url(1); return $this->getPageLinkWrapper($url, $text, 'first'); } /** * Get the next page pagination element. * * @param string $text * @return string */ //New end page method Public function last ($text = 'last page') { // If the current page is greater than or equal to the last page, it means we // can't go any further into the pages, as we're already on this last page // that is available, so we will make it the "next" link style disabled. $url = $this->paginator->url($this->paginator->lastPage()); return $this->getPageLinkWrapper($url, $text, 'last'); } }
Оригинал: “https://developpaper.com/laravel-page-style-replacement-add-the-first-page-and-the-last-page/”