zoukankan      html  css  js  c++  java
  • LARAVEL 分页

    自定义

    public function index(Request $request)
    {
    $list = DB::table('auth_group')->where('status','!=','-1')->get()->toArray();
    //dd($list);
    $perPage = 3;
    if ($request->has('page')) {
    $current_page = $request->page;
    $current_page = $current_page <= 0 ? 1 :$current_page;
    } else {
    $current_page = 1;
    }
    $item = array_slice($list, ($current_page-1)*$perPage, $perPage); //注释1
    $total = count($list);
    $paginator =new LengthAwarePaginator($item, $total, $perPage, $current_page, [
    'path' => Paginator::resolveCurrentPath(), //注释2
    'pageName' => 'page',
    ]);
    $list = $paginator->toArray()['data'];
    return view('AuthManager.index', compact('list', 'paginator')); //
    //return view('AuthManager.index',['list'=>$list]);
    }

    <div class="pages">
    {{ $paginator->render() }}
    </div>

    样式

    <link rel="stylesheet" href="{{asset('css/app.css')}}">

    简单模式

    $list = DB::table('auth_group')->where('status','!=','-1')->paginate(1);

    调用

    {{$list->links()}}

  • 相关阅读:
    ExecuteScalar 返回值问题
    c#中怎么用for循环遍历DataTable中的数据
    select多用户之间通信
    python快速学习6
    python快速学习5
    python快速学习4
    python快速学习3
    python快速学习2
    arm处理器
    软链接与硬链接
  • 原文地址:https://www.cnblogs.com/simadongyang/p/7605266.html
Copyright © 2011-2022 走看看