sort a Laravel query builder result by multiple columns | Laravel Point

 sort a Laravel query builder result by multiple columns

You can sort a Laravel query builder result by multiple columns using the orderBy method. Here's an example of how you can sort a query builder result by multiple columns in Laravel:

       $results = DB::table('table_name')
                ->orderBy('column1', 'asc')
                ->orderBy('column2', 'desc')
                ->get();

In this example, the query builder will first sort the result set by column1 in ascending order and then by column2 in descending order.

Previous Post Next Post

Contact Form