Laravel5默认分页

时间:2015-05-03 18:20:36

标签: laravel-5 laravel-pagination

简单地说这个

时出错了

->paginate(15);

我的代码下面有什么问题

<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Order;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator as Paginator;

class OrderController extends Controller {

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {   
        $this->middleware('auth');  
    }   
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        $orders = Order::with('customer')->get()->paginate(5);
        return view('order.index', compact('orders'));
    }

}
如果有人可以向我强调我做错了什么,那就表示赞赏了吗?

1 个答案:

答案 0 :(得分:1)

使用paginate()

时删除get()
$orders = Order::with('customer')->paginate(15);