小编Pra*_*war的帖子

第 2 页上的 Laravel 自定义分页作为对象返回

Laravel 自定义分页第 2 页结果作为对象而不是数组返回。

这是我的自定义分页代码

function custom_paginate($data)
{
    //Get current page form url e.g. &page=6
    $currentPage = LengthAwarePaginator::resolveCurrentPage();

    //Create a new Laravel collection from the array data
    $collection = new Collection($data);

    //Define how many items we want to be visible in each page
    $per_page = (int) per_page();

    //Slice the collection to get the items to display in current page
    $currentPageResults = $collection->slice(($currentPage - 1) * $per_page, $per_page)->all();

    //Create our paginator and add it to the data array
    $data['results'] = new …
Run Code Online (Sandbox Code Playgroud)

php pagination laravel

5
推荐指数
1
解决办法
1344
查看次数

标签 统计

laravel ×1

pagination ×1

php ×1