Sunday, 11 April 2021

Laravel raw expression in eloquent

 https://laravel.com/docs/5.0/queries#raw-expressions

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

No comments:

Post a Comment