67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Currency;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class CurrencySeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* Seeds the global currencies table with the four currencies
|
|
* supported by the Vernova platform. These are platform-level
|
|
* records and are not tenant-scoped.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Truncate to ensure a clean state on re-seed
|
|
DB::statement('PRAGMA foreign_keys=OFF;');
|
|
Currency::truncate();
|
|
DB::statement('PRAGMA foreign_keys=ON;');
|
|
|
|
$currencies = [
|
|
[
|
|
'code' => 'IRR',
|
|
'name' => 'Iranian Rial',
|
|
'symbol' => '﷼',
|
|
'decimal_places' => 0,
|
|
'exchange_rate_to_usd' => 42000.000000,
|
|
'is_active' => true,
|
|
],
|
|
[
|
|
'code' => 'USD',
|
|
'name' => 'US Dollar',
|
|
'symbol' => '$',
|
|
'decimal_places' => 2,
|
|
'exchange_rate_to_usd' => 1.000000,
|
|
'is_active' => true,
|
|
],
|
|
[
|
|
'code' => 'EUR',
|
|
'name' => 'Euro',
|
|
'symbol' => '€',
|
|
'decimal_places' => 2,
|
|
'exchange_rate_to_usd' => 0.920000,
|
|
'is_active' => true,
|
|
],
|
|
[
|
|
'code' => 'AED',
|
|
'name' => 'UAE Dirham',
|
|
'symbol' => 'د.إ',
|
|
'decimal_places' => 2,
|
|
'exchange_rate_to_usd' => 3.670000,
|
|
'is_active' => true,
|
|
],
|
|
];
|
|
|
|
foreach ($currencies as $currency) {
|
|
Currency::create($currency);
|
|
}
|
|
|
|
$this->command->info('Currencies seeded: ' . count($currencies) . ' records created.');
|
|
}
|
|
}
|