LeePC
我们努力不是为了成为金字塔上的人,我们努力是为了超越自己,使得自己变的更好。

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

废话不说上码

控制器LeeController.php层

 1 <?php 
 2 namespace App\Http\controllers;
 3 
 4 use App\Lee;
 5 use Illuminate\Support\Facades\DB;
 6 use Illuminate\Http\Request;
 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

分页类文件路径\vendor\laravel\framework\src\Illuminate\Pagination\LengthAwarePaginator.php

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

 

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

 报错提示

 

posted on 2017-04-29 11:05  三哥~!  阅读(2239)  评论(0编辑  收藏  举报