@@ -0,0 +1,23 @@
|
||||
<?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()]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user