added ons
This commit is contained in:
@@ -139,6 +139,7 @@ class ReportController extends Controller
|
||||
|
||||
$payload['up'] = $this->buildUpDownPrices();
|
||||
$payload['last_historical'] = app(ProductDisplayPriceService::class)->resolveHistoricalBasePrice();
|
||||
$payload['gold_ounce'] = $this->resolveGoldOuncePayload();
|
||||
app(ProductDisplayPriceService::class)->cacheLivePricePayload($payload);
|
||||
|
||||
$isFreshPrice = $saveFullCache || request()->boolean('force_refresh');
|
||||
@@ -164,6 +165,29 @@ class ReportController extends Controller
|
||||
return $payload;
|
||||
}
|
||||
|
||||
protected function resolveGoldOuncePayload(): ?array
|
||||
{
|
||||
$config = app(ConfigService::class);
|
||||
if (! $config->getBool('show_gold_ounce_price', false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$zaarbox = app(ZaarboxPriceService::class);
|
||||
if (! $zaarbox->hasApiUrlConfigured()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ounce = $zaarbox->fetchOuncePrice();
|
||||
if (($ounce['price'] ?? 0) <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'price' => (int) $ounce['price'],
|
||||
'label' => trim((string) ($ounce['name'] ?? 'انس طلا')) ?: 'انس طلا',
|
||||
];
|
||||
}
|
||||
|
||||
public function lastPrice(Request $request)
|
||||
{
|
||||
$config = app(ConfigService::class);
|
||||
|
||||
Reference in New Issue
Block a user