laravel eloquent sum of multiplied columns

Solutions on MaxInterview for laravel eloquent sum of multiplied columns by the best coders in the world

showing results for - "laravel eloquent sum of multiplied columns"
Ana
25 Feb 2018
1$amount = Transaction::sum(\DB::raw('jumla * harga'));
2
Angela
20 Mar 2016
1$amount = Transaction::select(DB::raw('sum(jumlah * harga) as total'))->get();
2
Maceo
21 Sep 2016
1$amount = Transaction::all()->sum(function($t){ 
2    return $t->jumlah * $t->harga; 
3});
4
similar questions
queries leading to this page
laravel eloquent sum of multiplied columns