39 lines
993 B
PHP
39 lines
993 B
PHP
<?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'],
|
|
];
|
|
|
|
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,
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|