Answers for "Laravel Eloquent sum of multiplied columns"

PHP
0

Laravel Eloquent sum of multiplied columns

$amount = Transaction::select(DB::raw('sum(jumlah * harga) as total'))->get();
Posted by: Guest on September-21-2021
0

Laravel Eloquent sum of multiplied columns

$amount = Transaction::all()->sum(function($t){ 
    return $t->jumlah * $t->harga; 
});
Posted by: Guest on September-21-2021
0

Laravel Eloquent sum of multiplied columns

$amount = Transaction::sum(\DB::raw('jumla * harga'));
Posted by: Guest on September-21-2021

Code answers related to "Laravel Eloquent sum of multiplied columns"

Browse Popular Code Answers by Language