Laravel 中的反向产品列表

Reverse product list in Laravel

如何反转Laravel中的产品列表? 下面是代码:

public function index() {
    $products = Product::with('owner', 'memberInfo')->paginate($this->perPage);
    return View::make('layouts.sales', array('products' => $products, 'status' => 'all'));
}

您可以将 Eloquent 的 reverse() 函数用于 collections。

public function index() {
    $products = Product::with('owner', 'memberInfo');
    $products = $products->reverse()->paginate($this->perPage);
    return View::make('layouts.sales', array('products' => $products, 'status' => 'all'));
}