Files
finance/app/Jobs/MergeCurrencyAndGoldRates.php
T
Ümit Tunç 09e981f94b Implement crypto currency rates feature and enhance API responses
- Added a new job to fetch crypto currency rates from an external source and store them in a JSON file.
- Updated the CurrencyController to include methods for retrieving current crypto currency rates and rates by name.
- Enhanced the API to return detailed metadata for crypto currency rates, including timestamps and update information.
- Updated the API routes to support new endpoints for crypto currency rates.
- Modified the merged rates JSON to include crypto currency data alongside existing currency and gold rates.
- Improved the welcome view to display additional crypto currency information, enhancing user experience.

These changes collectively expand the functionality of the Truncgil Finance application, providing users with comprehensive access to crypto currency data.
2025-01-21 19:27:03 +03:00

36 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
class MergeCurrencyAndGoldRates implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle()
{
$currencyData = $this->getData('currency/today.json');
$goldData = $this->getData('gold/today.json');
$cryptoCurrencyData = $this->getData('crypto/today.json');
// Verileri birleştir
$mergedData = array_merge($currencyData, $goldData, $cryptoCurrencyData);
// Birleştirilmiş veriyi dışarıya aktar
Storage::put('merged/rates.json', json_encode($mergedData, JSON_UNESCAPED_UNICODE));
}
private function getData($path)
{
if (Storage::exists($path)) {
return json_decode(Storage::get($path), true);
}
return [];
}
}