How to sort records in alphabetical order in Laravel

后端 未结 4 778
温柔的废话
温柔的废话 2020-12-17 19:17

How to sort records in alphabetical order in laravel?

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

    $items = Item::orderBy(\'nam         


        
4条回答
  •  半阙折子戏
    2020-12-17 19:53

    That's how you sort it, orderBy() comes after all():

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

    Reference: https://laravel.com/docs/5.5/collections

提交回复
热议问题