Laravel 5.4 sorting
The orderBy
method allows you to sort the result of the query by a given column. The first argument to the orderBy method should be the column you wish to sort by, while the second argument controls the direction of the sort and may be either asc
or desc
, check the example:
$users = DB::table('table')->orderBy('name', 'desc') // You can pass as many columns as you required->get();