40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
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'],
|
||
|
'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,
|
||
|
]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|