/** * @param $item Item * @return ItemPrice */ public function getItemPrice($item) { $params = ['currency' => $this->currency, 'appid' => $item->getAppId(), 'market_hash_name' => $item->getMarketName()]; $query = http_build_query($params); $price = ItemPrice::where('class_id', $item->getClassId())->where('app_id', $item->getAppId())->first(); // Пытаемся достать из файлового кеша, если нифига - берем из маркета if (!$price) { $url = $this->communityURL . 'market/priceoverview/?' . $query; $contents = @file_get_contents($url); $result = json_decode($contents, true); if (!$result['success']) { throw new NotFoundHttpException('Стим считает нас дудосерами по ссылке ' . $url); } $lowest = isset($result['lowest_price']) ? $this->cleanFloat($result['lowest_price']) : 0; $median = isset($result['median_price']) ? $this->cleanFloat($result['median_price']) : 0; $volume = isset($result['volume']) ? $this->cleanInt($result['volume']) : 0; $cached = ['class_id' => $item->getClassId(), 'app_id' => $item->getAppId(), 'min' => $lowest, 'median' => $median, 'volume' => $volume]; $price = ItemPrice::create($cached); } return $price; }