Laravel Eloquent sum of multiplied columns

39

$amount = Transaction::select(DB::raw('sum(jumlah * harga) as total'))->get();
$amount = Transaction::sum(\DB::raw('jumla * harga'));
$amount = Transaction::all()->sum(function($t){ 
    return $t->jumlah * $t->harga; 
});

Comments

Submit
0 Comments