StocksNew/database/seeders/DropdownSeeder.php
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +05:45

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,
]);
}
}
}
}
}