Exemple #1
0
 static function subtotal()
 {
     $sum = 0;
     $qty = static::all();
     $goods = Product::all(array_keys($qty));
     foreach ($goods as $product) {
         $sum += $qty[$product->id] * $product->retail;
     }
     return $sum;
 }