11106995d4
- 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.
35 lines
972 B
PHP
35 lines
972 B
PHP
<?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 [];
|
||
}
|
||
}
|