初始化

This commit is contained in:
2026-08-08 18:27:38 +08:00
parent efc150c937
commit 060eb79c09
336 changed files with 24613 additions and 15 deletions
+28
View File
@@ -0,0 +1,28 @@
<?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);
}
}
}