Example #1
0
 public function items()
 {
     if (!empty($this->item_data)) {
         return $this->item_data;
         //return the cached version
     } else {
         foreach ($this->bin as $key => $qty) {
             $item = Item::withKey($key);
             if ($detail = $item->loadDetail()) {
                 $this->item_data[$key] = $detail;
                 $this->item_data[$key]->total = $item->getPrice() * $qty;
                 $this->item_data[$key]->qty = $qty;
                 $this->item_data[$key]->key = $key;
             } else {
                 $this->remove($item);
             }
         }
         return $this->item_data;
     }
 }