如何在Laravel中按字母顺序对记录进行排序

How to sort records in alphabetical order in laravel?

public function index()
{
    $comproducts = Comproduct::paginate(3);

    $items = Item::orderBy('name')->all();        

    return view('computer', compact(['comproducts', 'items']));

}

This is not working correctly. This shows

Call to undefined method Illuminate\Database\Query\Builder::all()

this error. How can i fix this?

查看全部
duanliaoyu8419
duanliaoyu8419
2017/11/12 08:10
  • laravel
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复