Laravel 8 havingRaw / orHavingRaw
havingRaw
和 orHavingRaw
方法可以用于将原生字符串设置为 having
语句的值:
$orders = DB::table('orders')
->select('department', DB::raw('SUM(price) as total_sales'))
->groupBy('department')
->havingRaw('SUM(price) > ?', [2500])
->get();