脚本宝典收集整理的这篇文章主要介绍了Laravel框架实现超简单的分页效果示例,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了Laravel框架实现超简单的分页效果。分享给大家供大家参考,具体如下:
每页展示5条数据
控制器
class indexCo extends Controller { public function cc () { $lists = UserAli:: orderBy('user_id','desc') -> paginate(5); return view('cc',compact('lists')); } }
layout/main.blade.php
<!DOCTYPE htML> <html> <head> <tITle>Home</title> <link rel="stylesheet" href="http://cdn.bootcss.COM/bootstrap/3.3.4/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" > </head> <body> <h1>Home</h1> <p>Welcome to My web</p> </body> </html> <!DOCTYPE html> <html> <head> <title>About</title> </head> <body> <h1>About</h1> <p>This is my First Laravel web</p> @yield("content") </body> </html>
cc模板
view/cc.blade.php
@extends('layout.main') @section("content") <div> @foreach($lists as $value) <div> 阿里账号是:{{$value -> source}} <time>{{$value -> add_time}}</time> </div> @enDForeach </div> {{$lists -> links()}} @endsection
两句话搞定分页。
当然,blade模板需要引入bootstrap,否则样式是出不来的。
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" >
更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。
以上是脚本宝典为你收集整理的Laravel框架实现超简单的分页效果示例全部内容,希望文章能够帮你解决Laravel框架实现超简单的分页效果示例所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。