前言
本文主要给大家介绍了关于laravel分页样式替换的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
方法如下:
一、自定义一个类(代码如下),位置随你放,注意命名空间。
二、模板输出调用 {!! $data->render(new AppHttpControllersShmilyThreePresenter($data)) !!}
最终样式
实现代码
hasPages()) {
return sprintf(
'',//自定义class样式
$this->firstPage(),//添加首页方法
$this->getPreviousButton('上一页'),
$this->getlinks(),
$this->getNextButton('下一页'),
$this->last()//添加尾页方法
);
}
return '';
}
protected function getAvailablePageWrapper($url, $page, $rel = null)
{
$rel = is_null($rel) ? '' : ' rel="'.$rel.'"';
return '
'.$page.'';
//这里li标签可以添加你自己的class样式
}
protected function getDisabledTextWrapper($text)
{
return '
'.$text.'';
}
protected function getActivePageWrapper($text)
{
return '
'.$text.'';
}
//新建首页方法
public function firstPage($text = '首页')
{
// 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');
}
//新建尾页方法
public function last($text = '尾页')
{
// 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');
}
}
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对考高分网的支持。