源生sql
select from (select from service_order order by order_time asc) a group by a.company_id;

 $subQuery = ServiceOrder::select(['id', 'company_id', 'service_id', 'order_time'])
            ->where('project', 'yundou')
            ->orderBy('order_time', 'asc');

    $sql = $subQuery->toSql();

    $query = DB::table(DB::raw("({$sql}) as sub"))
            ->groupBy('sub.company_id');
    $result = $query->mergeBindings($subQuery->getQuery())->paginate(10);