Monday, March 6, 2017

Apply more than one orderBy in Laravel Schema Builder

I know we can create a schema builder and order by base on specific column in Laravel

$visitors = Visitor::orderBy('visit_count', 'desc')
        ->orderBy('updated_at', 'desc')
        ->where('os', 'not like', '%bot%')
        ->where('country', '=', 'US')
        ->get();

But I am not sure - if we can apply more than one orderBy condition. Can we do that ?

For Ex. Get all the visitors order by visit_count AND show the latest one first ...

Any advises or tips for me ?



via ihue

Advertisement