欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Laravel框架實現(xiàn)超簡單的分頁效果示例

 更新時間:2019年02月08日 11:18:40   作者:cofecode  
這篇文章主要介紹了Laravel框架實現(xiàn)超簡單的分頁效果,結(jié)合實例形式分析了Laravel框架實現(xiàn)分頁功能的相關(guān)控制器、視圖、模板調(diào)用等相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了Laravel框架實現(xiàn)超簡單的分頁效果。分享給大家供大家參考,具體如下:

每頁展示5條數(shù)據(jù)

控制器

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"  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

兩句話搞定分頁。

當(dāng)然,blade模板需要引入bootstrap,否則樣式是出不來的。

<link rel="stylesheet"  rel="external nofollow" rel="external nofollow" >

更多關(guān)于Laravel相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Laravel框架入門與進階教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家基于Laravel框架的PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論