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.

38 lines
1.1 KiB

1 week ago
<?php
namespace Database\Seeders;
use App\Models\DictItem;
use App\Models\DictType;
use Illuminate\Database\Seeder;
/**
* 资讯分类下拉:政策信息 / 行业动态 / 活动通知(与 prototype news-create.html 一致)。
*/
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]
);
}
}
}