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.

53 lines
1.6 KiB

4 weeks ago
<?php
namespace Database\Seeders;
use App\Models\DictItem;
use App\Models\DictType;
4 days ago
use App\Support\News\UniversityNewsCategory;
4 weeks ago
use Illuminate\Database\Seeder;
/**
4 days ago
* 资讯分类下拉:政策信息 / 行业动态 / 活动通知 / 高校要闻。
4 weeks ago
*/
class NewsDictionarySeeder extends Seeder
{
public function run(): void
{
$type = DictType::query()->updateOrCreate(
['code' => 'news_category'],
[
'name' => '资讯分类',
'remark' => '资讯管理-分类下拉',
'status' => 1,
'sort' => 51,
]
);
foreach ([
['label' => '政策信息', 'value' => 'policy', 'sort' => 10],
['label' => '行业动态', 'value' => 'industry', 'sort' => 20],
['label' => '活动通知', 'value' => 'activity_notice', 'sort' => 30],
] as $row) {
DictItem::query()->updateOrCreate(
['dict_type_id' => $type->id, 'value' => $row['value']],
['label' => $row['label'], 'sort' => $row['sort'], 'status' => 1]
);
}
4 days ago
// 先合并历史重复项,再按 value 唯一维护「高校要闻」(爬虫地址绑定沿用原 ID
UniversityNewsCategory::consolidateDuplicates();
DictItem::query()->updateOrCreate(
['dict_type_id' => $type->id, 'value' => UniversityNewsCategory::VALUE],
[
'label' => UniversityNewsCategory::LABEL,
'sort' => 40,
'status' => 1,
]
);
UniversityNewsCategory::consolidateDuplicates();
4 weeks ago
}
}