Files
Investidor-V2/database/seeders/InvestmentReferenceSeeder.php
nala 250ac35fd1
tests / ci (push) Canceled after 0s
first commit
2026-09-28 10:01:09 +02:00

24 lines
883 B
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
class InvestmentReferenceSeeder extends Seeder
{
public function run(): void
{
$groups = json_decode(File::get(database_path('data/investment-reference-options.json')), true, 512, JSON_THROW_ON_ERROR);
DB::transaction(function () use ($groups) {
foreach ($groups as $group => $options) {
foreach ([...$options, 'other' => 'Outro — especificar'] as $code => $label) {
DB::table('investment_reference_options')->insertOrIgnore(['group' => $group, 'code' => $code, 'label' => $label,
'active' => true, 'requires_description' => $code === 'other', 'created_at' => now(), 'updated_at' => now()]);
}
}
});
}
}