added ons
This commit is contained in:
@@ -167,25 +167,7 @@ class ReportController extends Controller
|
||||
|
||||
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'] ?? 'انس طلا')) ?: 'انس طلا',
|
||||
];
|
||||
return app(ZaarboxPriceService::class)->clientGoldOuncePayload();
|
||||
}
|
||||
|
||||
public function lastPrice(Request $request)
|
||||
@@ -197,6 +179,8 @@ class ReportController extends Controller
|
||||
if (! $forceRefresh) {
|
||||
$cached = $cache->get();
|
||||
if ($cached !== null) {
|
||||
$cached['gold_ounce'] = $this->resolveGoldOuncePayload();
|
||||
|
||||
return $cached;
|
||||
}
|
||||
|
||||
@@ -204,7 +188,7 @@ class ReportController extends Controller
|
||||
if ($cache->hasRecentTick()) {
|
||||
$dbBuilt = $cache->buildFromDatabase();
|
||||
if (($dbBuilt['price'] ?? 0) > 0) {
|
||||
return $cache->put($dbBuilt);
|
||||
return $this->appendUpPrices($dbBuilt, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user