Files
finance/app/Jobs/MergeCurrencyAndGoldRates.php
Ümit Tunç 11106995d4 Add MergeCurrencyAndGoldRates job to combine currency and gold rates
- Introduced a new job class `MergeCurrencyAndGoldRates` to handle the merging of currency and gold rate data.
- Implemented a method to retrieve data from JSON files stored in the application.
- Merged the fetched currency and gold data into a single array.
- Stored the combined data in a new JSON file for easy access and further processing.

This commit enhances the application's ability to manage and utilize financial data by integrating currency and gold rates into a unified format.
2025-01-17 22:58:51 +03:00

35 lines
972 B
PHP
Raw Permalink 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');
// Verileri birleştir
$mergedData = array_merge($currencyData, $goldData);
// 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 [];
}
}