初始化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user