Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rodrigodonha's avatar

How do add (sum) a column value with other value in query builder laravel?

in MySql: SELECT *, cost_value + 1000.00 final_value FROM kits WHERE CODE = '231486V'

But in Laravel Query: DB::table('kits') ->select('*') ->select(DB::raw('SUM(cost_value + 1000.00) filnal_price')) ->orderBy('cost_value') ->get(); not work

In Laravel documentation not found a soluction.

0 likes
1 reply
MohamedTammam's avatar
DB::table('kits')
->select(['*', DB::raw('SUM(cost_value + 1000.00) filnal_price')])
->orderBy('cost_value')
->get();

Please or to participate in this conversation.