You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
5.5 KiB

2 weeks ago
<?php
namespace Database\Seeders;
use App\Models\DictItem;
use App\Models\DictType;
use Illuminate\Database\Seeder;
/**
* 课程模块下拉:课程体系、课程类型、是否(与 prototype course-create.html / course-options 默认一致)。
* 课程表存 dict_items.id勿存中文文案。
*/
class CourseDictionarySeeder extends Seeder
{
public function run(): void
{
$systemType = DictType::query()->updateOrCreate(
['code' => 'course_system'],
[
'name' => '课程体系',
'remark' => '课程管理-课程体系下拉;对齐 prototype 默认 AI/材料/交叉学科',
'status' => 1,
'sort' => 40,
]
);
$typeType = DictType::query()->updateOrCreate(
['code' => 'course_type'],
[
'name' => '课程类型',
'remark' => '课程管理-类型下拉;对齐 prototype 默认 公益/付费',
'status' => 1,
'sort' => 41,
]
);
$yesNo = DictType::query()->updateOrCreate(
['code' => 'yes_no'],
[
'name' => '是否',
'remark' => '通用是否;课程「已审核学员自动入老师库」等',
'status' => 1,
'sort' => 42,
]
);
foreach ([
['label' => 'AI', 'value' => 'AI', 'sort' => 10],
['label' => '材料', 'value' => '材料', 'sort' => 20],
['label' => '交叉学科', 'value' => '交叉学科', 'sort' => 30],
] as $row) {
DictItem::query()->updateOrCreate(
[
'dict_type_id' => $systemType->id,
'value' => $row['value'],
],
[
'label' => $row['label'],
'sort' => $row['sort'],
'status' => 1,
]
);
}
foreach ([
['label' => '公益', 'value' => '公益', 'sort' => 10],
['label' => '付费', 'value' => '付费', 'sort' => 20],
] as $row) {
DictItem::query()->updateOrCreate(
[
'dict_type_id' => $typeType->id,
'value' => $row['value'],
],
[
'label' => $row['label'],
'sort' => $row['sort'],
'status' => 1,
]
);
}
foreach ([
['label' => '是', 'value' => 'yes', 'sort' => 10],
['label' => '否', 'value' => 'no', 'sort' => 20],
] as $row) {
DictItem::query()->updateOrCreate(
[
'dict_type_id' => $yesNo->id,
'value' => $row['value'],
],
[
'label' => $row['label'],
'sort' => $row['sort'],
'status' => 1,
]
);
}
$genderType = DictType::query()->updateOrCreate(
['code' => 'signup_gender'],
[
'name' => '报名-性别',
'remark' => '课程报名表单下拉/单选;存库 key=dict_items.id',
'status' => 1,
'sort' => 43,
]
);
$educationType = DictType::query()->updateOrCreate(
['code' => 'signup_education'],
[
'name' => '报名-最高学历',
'remark' => '课程报名表单下拉;存库 key=dict_items.id',
'status' => 1,
'sort' => 44,
]
);
$channelType = DictType::query()->updateOrCreate(
['code' => 'signup_channel'],
[
'name' => '报名-渠道',
'remark' => '预留报名渠道;表单 options_source.dict_code=signup_channel',
'status' => 1,
'sort' => 45,
]
);
foreach ([
['label' => '男', 'value' => 'male', 'sort' => 10],
['label' => '女', 'value' => 'female', 'sort' => 20],
] as $row) {
DictItem::query()->updateOrCreate(
['dict_type_id' => $genderType->id, 'value' => $row['value']],
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
);
}
foreach ([
['label' => '专科', 'value' => 'college', 'sort' => 10],
['label' => '本科', 'value' => 'bachelor', 'sort' => 20],
['label' => '硕士', 'value' => 'master', 'sort' => 30],
['label' => '博士', 'value' => 'doctor', 'sort' => 40],
] as $row) {
DictItem::query()->updateOrCreate(
['dict_type_id' => $educationType->id, 'value' => $row['value']],
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
);
}
foreach ([
['label' => '官网', 'value' => 'web', 'sort' => 10],
['label' => '微信公众号', 'value' => 'wechat', 'sort' => 20],
['label' => '线下活动', 'value' => 'offline', 'sort' => 30],
] as $row) {
DictItem::query()->updateOrCreate(
['dict_type_id' => $channelType->id, 'value' => $row['value']],
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
);
}
}
}