一般是这样写 Model::query()->paginate()
不能这样 Order::where('status', 1)->get()->paginate()已经使用了get,再使用paginate就会有问题。get/all/first/paginate等是最后的执行方法。
使用get/all后会返回一个集合,first会返回一条数据,paginate返回分页数据
这个简单,你直接在模板上搞个 首页链接,和尾页链接就好了。 还有一个方案是,你用paginate(15) 返回数据,你会发现 这个数据会有每个页面的数据,当前页数,总页数,你根据这些数据来写html代码,就可以了//设置分页容器 /app/models/ZurbPresenter.php<?php
class ZurbPresenter extends Illuminate\Pagination\Presenter {
public function getPageLinkWrapper($url, $page, $rel = null)
{
$rel = is_null($rel) ? '' : ' rel="'.$rel.'"'
return '<li><a href=javascript:goodslist("'.$url.'")>'.$page.'</a></li>'
}
public function getDisabledTextWrapper($text)
{
return '<li class="disabled"><span>'.$text.'</span></li>'
}
public function getActivePageWrapper($text)
{
return '<li class="active"><span>'.$text.'</span></li>'
}
}
//设置分页模板 /app/view/page/page.blade.php
<ul class="pagination">
<?php echo with(new ZurbPresenter($paginator))->render()?>
</ul>
//设置配置文件 /app/config/view.php
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)