zoukankan      html  css  js  c++  java
  • [Laravel] 自带分页实现以及links方法不存在错误

    自带分页实现其实挺简单的,但是我在实现的时候报错!找了很久才找出原因!

    废话不说上码

    控制器LeeController.php层

     1 <?php 
     2 namespace AppHttpcontrollers;
     3 
     4 use AppLee;
     5 use IlluminateSupportFacadesDB;
     6 use IlluminateHttpRequest;
     7 
     8 
     9 class LeeController extends Controller {
    10 
    11     public function index(){
    12         $famous = Lee::getFamous();//调用名言
    13         $article = DB::table('lee_article')->paginate(12);//调用文章
    14         //print_r($article);die;
    15         return view('index',[
    16             'famous'=> $famous,
    17             'article'=> $article
    18             ]);
    19     }
    20 
    21 }

    视图层index.blade.php

    1 <!-- 分页 -->
    2 <div class="project-pages">
    3<ul>
    4<li>{!! $article->links() !!}</li>
    5                                       
    6 </ul>
    7 </div>
    8 <!-- 分页 -->

    我的错误原因是是框架的分页类中没有links这个方法,在分页类中加上这个links方法就OK

    分页类文件路径vendorlaravelframeworksrcIlluminatePaginationLengthAwarePaginator.php

    下面是links的方法,在这个分页类文件后面加上这个方法就OK啦!

     1 /**
     2      * Render the paginator using the given presenter.
     3      *
     4      * @param  IlluminateContractsPaginationPresenter|null  $presenter
     5      * @return string
     6      */
     7     public function links(Presenter $presenter = null)
     8     {
     9         return $this->render($presenter);
    10     }

     报错提示

  • 相关阅读:
    安装Python及pip
    关于软件测试培训
    终于也为自己开了技术博客
    全球地址联动js包2021最新
    约瑟夫斯问题
    添加二级域名
    mysql导出数据
    mysql导入数据
    shopify
    MySQL数据库简介及常用命令
  • 原文地址:https://www.cnblogs.com/lipcblog/p/6784701.html
Copyright © 2011-2022 走看看