Files
2026-08-08 18:27:38 +08:00

29 lines
1.0 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\Category;
use Illuminate\Database\Seeder;
class CategorySeeder extends Seeder
{
public function run(): void
{
$products = [
['name' => 'PD 电源及其信号智能控制 IC', 'slug' => 'pd-phy-controller', 'type' => 'product', 'sort' => 1],
['name' => '协议转换 IC', 'slug' => 'protocol-bridge', 'type' => 'product', 'sort' => 2],
['name' => '同步整流 IC', 'slug' => 'sync-rectifier', 'type' => 'product', 'sort' => 3],
];
$articles = [
['name' => '设计指南', 'slug' => 'design-guide', 'type' => 'article', 'sort' => 1],
['name' => '应用笔记', 'slug' => 'app-note', 'type' => 'article', 'sort' => 2],
['name' => '行业方案', 'slug' => 'industry-solution', 'type' => 'article', 'sort' => 3],
];
foreach (array_merge($products, $articles) as $cat) {
Category::firstOrCreate(['slug' => $cat['slug']], $cat);
}
}
}