关于php:Laravel-的分页

40次阅读

共计 454 个字符,预计需要花费 2 分钟才能阅读完成。

$per_page = $request->input("per_page", 20);

$users = DB::table('users')->paginate(15);
# 或者
$users = App\User::where('votes', '>', 100)->paginate($per_page);

foreach($users as $user){}
{
   "total": 50,
   "per_page": 15,
   "current_page": 1,
   "last_page": 4,
   "first_page_url": "http://laravel.app?page=1",
   "last_page_url": "http://laravel.app?page=4",
   "next_page_url": "http://laravel.app?page=2",
   "prev_page_url": null,
   "path": "http://laravel.app",
   "from": 1,
   "to": 15,
   "data":[
        {// 后果对象集},
        {// 后果对象集}
   ]
}

正文完
 0