Dashboard sipadu mbip
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AuctionSale.php 896B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Model\Module;
  3. Use App\Model\Module\Inventori;
  4. class AuctionSale
  5. {
  6. public $items = null;
  7. public $totalQty = 0;
  8. public $totalPrice = 0;
  9. public function __construct($oldCart)
  10. {
  11. if ($oldCart){
  12. $this->items=$oldCart->items;
  13. $this->totalQty=$oldCart->totalQty;
  14. $this->totalPrice=$oldCart->totalPrice;
  15. }
  16. }
  17. public function add($item, $id, $harga, $barcode){
  18. // $inv = Inventori::where('_id',$id)->first();
  19. $storedItem = ['qty'=>0,'price'=>$harga, 'item'=>$item, 'barcode'=>array()];
  20. if($this->items){
  21. if(array_key_exists($id, $this->items))
  22. {
  23. $storedItem = $this->items[$id];
  24. }
  25. }
  26. $storedItem['qty']++;
  27. $storedItem['price'] = $harga * $storedItem['qty'];
  28. array_push($storedItem['barcode'], $barcode);
  29. $this->items[$id] = $storedItem;
  30. $this->totalQty++;
  31. $this->totalPrice += $harga;
  32. }
  33. }