阅读(3509) (7)

Laravel 8 havingRaw / orHavingRaw

2021-07-07 09:14:21 更新

havingRaworHavingRaw 方法可以用于将原生字符串设置为 having 语句的值:

$orders = DB::table('orders')
                ->select('department', DB::raw('SUM(price) as total_sales'))
                ->groupBy('department')
                ->havingRaw('SUM(price) > ?', [2500])
                ->get();