Feat: Adds multi currency support (#88)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Currency;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CurrencySeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
||||
Currency::insert([
|
||||
['currency' => 'AUD', 'label' => 'Australian Dollar', 'created_at' => now()],
|
||||
['currency' => 'BRL', 'label' => 'Brazilian Real', 'created_at' => now()],
|
||||
['currency' => 'GBP', 'label' => 'British Pound', 'created_at' => now()],
|
||||
['currency' => 'CAD', 'label' => 'Canadian Dollar', 'created_at' => now()],
|
||||
['currency' => 'CNY', 'label' => 'Chinese Yuan', 'created_at' => now()],
|
||||
['currency' => 'CZK', 'label' => 'Czech Koruna', 'created_at' => now()],
|
||||
['currency' => 'DKK', 'label' => 'Danish Krone', 'created_at' => now()],
|
||||
['currency' => 'EUR', 'label' => 'Euro', 'created_at' => now()],
|
||||
['currency' => 'HKD', 'label' => 'Hong Kong Dollar', 'created_at' => now()],
|
||||
['currency' => 'INR', 'label' => 'Indian Rupee', 'created_at' => now()],
|
||||
['currency' => 'JPY', 'label' => 'Japanese Yen', 'created_at' => now()],
|
||||
['currency' => 'NZD', 'label' => 'New Zealand Dollar', 'created_at' => now()],
|
||||
['currency' => 'NOK', 'label' => 'Norwegian Krone', 'created_at' => now()],
|
||||
['currency' => 'SGD', 'label' => 'Singapore Dollar', 'created_at' => now()],
|
||||
['currency' => 'KRW', 'label' => 'South Korean Won', 'created_at' => now()],
|
||||
['currency' => 'ZAR', 'label' => 'South African Rand', 'created_at' => now()],
|
||||
['currency' => 'SEK', 'label' => 'Swedish Krona', 'created_at' => now()],
|
||||
['currency' => 'CHF', 'label' => 'Swiss Franc', 'created_at' => now()],
|
||||
['currency' => 'USD', 'label' => 'United States Dollar', 'created_at' => now()],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
|
||||
@@ -41,22 +41,21 @@ class MarketDataSeeder extends Seeder
|
||||
|
||||
$data = array_combine($header, $row);
|
||||
|
||||
$meta_data = json_decode(base64_decode($data['meta_data']), true);
|
||||
$meta_data['source'] = 'market_data_seeder';
|
||||
|
||||
$this->rows[] = [
|
||||
'symbol' => $data['symbol'],
|
||||
'name' => $data['name'],
|
||||
'meta_data' => json_encode([
|
||||
'country' => $data['country'],
|
||||
'first_trade_year' => $data['first_trade_year'],
|
||||
'sector' => $data['sector'],
|
||||
'industry' => $data['industry'],
|
||||
]),
|
||||
'currency' => $data['currency'],
|
||||
'meta_data' => json_encode($meta_data),
|
||||
];
|
||||
|
||||
$rowCount++;
|
||||
|
||||
if ($rowCount % $chunkSize == 0) {
|
||||
|
||||
$this->bulkInsert($this->rows);
|
||||
DB::table('market_data')->upsert($this->rows, ['symbol'], ['name', 'currency', 'meta_data']);
|
||||
$this->rows = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14465
-34981
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user