protected function setOrderByInQuery(QueryBuilder $query, array $orderBy): void
    {
        // Iterate through each order by
        foreach ($orderBy as $column => $order) {
            // Switch through the order (value) set
            switch ($order) {
                // If the order is ascending
                case OrderBy::ASC:
                    // Set the column via the orderByAsc method
                    $query->orderByAsc($column);
                    break;
                // If the order is descending
                case OrderBy::DESC:
                    // Set the column via the orderByDesc method
                    $query->orderByDesc($column);
                    break;
                default:
                    // Otherwise set the order (which is the column)
                    $query->orderBy($order);
                    break;
            }
        }
    }
protected function setOrderByInQuery(QueryBuilder $query, array $orderBy): void
    {
        // Iterate through each order by
        foreach ($orderBy as $column => $order) {
            // Switch through the order (value) set
            switch ($order) {
                // If the order is ascending
                case OrderBy::ASC:
                    // Set the column via the orderByAsc method
                    $query->orderByAsc($column);
                    break;
                // If the order is descending
                case OrderBy::DESC:
                    // Set the column via the orderByDesc method
                    $query->orderByDesc($column);
                    break;
                default:
                    // Otherwise set the order (which is the column)
                    $query->orderBy($order);
                    break;
            }
        }
    }
protected function setOrderByInQuery ( QueryBuilder $ query , array $ orderBy ) : void { // Iterate through each order by foreach ( $ orderBy as $ column => $ order ) { // Switch through the order (value) set switch ( $ order ) { // If the order is ascending case OrderBy :: ASC : // Set the column via the orderByAsc method $ query -> orderByAsc ( $ column ) ; break ; // If the order is descending case OrderBy :: DESC : // Set the column via the orderByDesc method $ query -> orderByDesc ( $ column ) ; break ; default : // Otherwise set the order (which is the column) $ query -> orderBy ( $ order ) ; break ; } } }
Set the order by options in a query builder.

@param QueryBuilder $query
@param array        $orderBy

@return void
Set the order by options in a query builder .