0

简单地说,我有一个错误

->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'));
    }

}

如果有人可以向我强调我做错了什么,我将不胜感激?

4

1 回答 1

1

使用 paginate() 时删除 get()

$orders = Order::with('customer')->paginate(15);
于 2015-05-04T01:38:04.217 回答