StocksNew/database/seeders/DropdownSeeder.php

40 lines
1.0 KiB
PHP
Raw Normal View History

2024-08-27 12:03:06 +00:00
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Modules\Admin\Models\Dropdown;
use Modules\Admin\Models\Field;
class DropdownSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$inputArr = [
'Gender' => ['Male', 'Female', 'Others'],
'Nationality' => ['Nepali', 'Others'],
'Ethnicity' => ['Brahmin', 'Chettri', 'Janajati', 'Others'],
'Ranking Type' => ['Promotion', 'Demotion'],
];
foreach ($inputArr as $key => $value) {
$fieldModel = Field::updateOrCreate(['title' => $key], [
'title' => $key,
]);
if ($fieldModel) {
foreach ($value as $k => $v) {
Dropdown::updateOrCreate(['title' => $v,
'fid' => $fieldModel->id], [
'title' => $v,
'fid' => $fieldModel->id,
]);
}
}
}
}
}