初始化

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
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('users');
}
};
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('contact_messages', function (Blueprint $table) {
$table->id();
$table->string('name', 40);
$table->string('email', 120);
$table->string('phone', 20)->nullable();
$table->string('subject', 80);
$table->text('message');
$table->string('ip', 45)->nullable();
$table->timestamps();
$table->index('email');
$table->index('created_at');
});
}
public function down(): void
{
Schema::dropIfExists('contact_messages');
}
};
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('is_admin')->default(false)->after('password');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('is_admin');
});
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->string('type')->default('product'); // product | article
$table->unsignedBigInteger('parent_id')->nullable();
$table->integer('sort')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('categories');
}
};
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('category_id')->nullable();
$table->string('name');
$table->string('slug')->unique();
$table->string('model')->nullable();
$table->string('summary')->nullable();
$table->text('description')->nullable();
$table->text('specs')->nullable();
$table->string('cover')->nullable();
$table->string('status')->default('published'); // published | draft
$table->integer('sort')->default(0);
$table->timestamps();
$table->softDeletes();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('set null');
});
}
public function down(): void
{
Schema::dropIfExists('products');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('category_id')->nullable();
$table->string('title');
$table->string('slug')->unique();
$table->string('summary')->nullable();
$table->text('body')->nullable();
$table->string('cover')->nullable();
$table->string('author')->nullable();
$table->string('status')->default('published'); // published | draft
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('set null');
});
}
public function down(): void
{
Schema::dropIfExists('articles');
}
};
@@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('glossary_terms', function (Blueprint $table) {
$table->id();
$table->string('term');
$table->string('slug')->unique();
$table->text('definition');
$table->string('aliases')->nullable();
$table->string('category')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('glossary_terms');
}
};
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('forum_boards', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->integer('sort')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('forum_boards');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('forum_threads', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('board_id');
$table->unsignedBigInteger('user_id');
$table->string('title');
$table->text('body');
$table->boolean('is_pinned')->default(false);
$table->boolean('is_locked')->default(false);
$table->unsignedInteger('views')->default(0);
$table->timestamp('last_reply_at')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('board_id')->references('id')->on('forum_boards')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('forum_threads');
}
};
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('forum_replies', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('thread_id');
$table->unsignedBigInteger('user_id');
$table->text('body');
$table->timestamps();
$table->softDeletes();
$table->foreign('thread_id')->references('id')->on('forum_threads')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('forum_replies');
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->text('value')->nullable();
$table->string('group')->default('general');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('settings');
}
};
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->unsignedInteger('points')->default(0)->after('is_admin');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('points');
});
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('articles', function (Blueprint $table) {
$table->string('template')->default('standard')->after('status');
$table->string('seo_title')->nullable()->after('template');
$table->string('seo_description')->nullable()->after('seo_title');
});
}
public function down(): void
{
Schema::table('articles', function (Blueprint $table) {
$table->dropColumn(['template', 'seo_title', 'seo_description']);
});
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('products', function (Blueprint $table) {
$table->string('seo_title')->nullable()->after('slug');
$table->string('seo_description')->nullable()->after('seo_title');
});
}
public function down(): void
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn(['seo_title', 'seo_description']);
});
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 5 级角色 + 细粒度权限(内部员工由管理员分配)。
* 存量用户默认 role='user';种子管理员会在 Seeder 中置为 super_admin。
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('role')->default('user')->after('is_admin');
$table->json('permissions')->nullable()->after('role');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['role', 'permissions']);
});
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 论坛楼/回帖增加审核状态。
* 默认 approved:存量内容(迁移前已存在)保持公开,不回流到待审。
* 新发布内容由控制器显式置为 pending。
*/
public function up(): void
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->string('status')->default('approved')->after('body');
});
Schema::table('forum_replies', function (Blueprint $table) {
$table->string('status')->default('approved')->after('body');
});
}
public function down(): void
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->dropColumn('status');
});
Schema::table('forum_replies', function (Blueprint $table) {
$table->dropColumn('status');
});
}
};
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 文章支持用户投稿:增加 user_id(投稿人,管理员发稿为 null)。
*
* 注意:articles.status 列在 000005 迁移中已存在(原语义 published/draft)。
* 此处不再重复加列,而是把语义扩展为统一集:
* approved(公开)| pending(用户投稿待审)| rejected(用户投稿驳回)| draft(管理员草稿)
* 存量 published 视为已审核公开,统一映射为 approved。
*
* 容错:user_id 可能已在一次失败的迁移中被 MySQL 隐式提交创建,故加存在性判断。
*/
public function up(): void
{
if (! Schema::hasColumn('articles', 'user_id')) {
Schema::table('articles', function (Blueprint $table) {
$table->foreignId('user_id')
->nullable()
->after('category_id')
->constrained('users')
->nullOnDelete();
});
}
DB::table('articles')
->where('status', 'published')
->update(['status' => 'approved']);
}
public function down(): void
{
if (Schema::hasColumn('articles', 'user_id')) {
Schema::table('articles', function (Blueprint $table) {
$table->dropConstrainedForeignId('user_id');
});
}
// 不回滚 status 取值,避免误伤已发布内容。
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 详细注册:在 users 表补充资料字段(均允许为空,降低注册门槛)。
* - real_name:真实姓名(与昵称 name 区分)
* - phone:手机号
* - company:公司名称
* - industry:行业/领域
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('real_name')->nullable()->after('name');
$table->string('phone')->nullable()->after('real_name');
$table->string('company')->nullable()->after('phone');
$table->string('industry')->nullable()->after('company');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['real_name', 'phone', 'company', 'industry']);
});
}
};
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('solutions', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->string('power_segment')->nullable(); // 功率段:lt30|30-65|65-100|gt100
$table->string('application')->nullable(); // 应用场景:charger|powerbank|car|dock
$table->string('chip_platform')->nullable(); // 芯片平台:protocol|soc|rectifier
$table->string('power')->nullable(); // 功率参数,如 65W
$table->string('summary')->nullable();
$table->text('advantages')->nullable(); // 方案优势,换行分隔
$table->text('description')->nullable();
$table->string('cover')->nullable();
$table->string('status')->default('published'); // published | draft
$table->integer('sort')->default(0);
$table->string('seo_title')->nullable();
$table->string('seo_description')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('solutions');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('news', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('slug')->unique();
$table->string('category')->default('industry'); // industry|company|event
$table->string('summary')->nullable();
$table->text('body')->nullable();
$table->string('cover')->nullable();
$table->string('status')->default('published'); // published | draft
$table->timestamp('published_at')->nullable();
$table->string('seo_title')->nullable();
$table->string('seo_description')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('news');
}
};
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 与 pd-tech-hub 对齐:联系表单增加「公司」字段,便于 B 端客户对接。
*/
public function up(): void
{
Schema::table('contact_messages', function (Blueprint $table) {
$table->string('company', 120)->nullable()->after('phone');
});
}
public function down(): void
{
Schema::table('contact_messages', function (Blueprint $table) {
$table->dropColumn('company');
});
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('navigation_menus', function (Blueprint $table) {
$table->id();
$table->string('label', 60)->comment('菜单显示文字');
$table->string('url', 255)->comment('链接地址(站内路径如 /about 或完整外链)');
$table->boolean('is_visible')->default(true)->comment('是否在前台显示');
$table->integer('sort_order')->default(0)->comment('排序,数字越小越靠前');
$table->timestamps();
$table->index(['is_visible', 'sort_order']);
});
}
public function down(): void
{
Schema::dropIfExists('navigation_menus');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('hero_slides', function (Blueprint $table) {
$table->id();
$table->string('location', 40)->default('home')->comment('展示位置(预留多页扩展,当前仅 home)');
$table->string('title', 120)->comment('后台标识 / 无障碍标题');
$table->text('content')->nullable()->comment('富文本正文(Quill 产出的 HTML');
$table->string('cta_text', 80)->nullable()->comment('主按钮文字');
$table->string('cta_url', 255)->nullable()->comment('主按钮链接');
$table->string('cta2_text', 80)->nullable()->comment('次按钮文字');
$table->string('cta2_url', 255)->nullable()->comment('次按钮链接');
$table->boolean('is_active')->default(true)->comment('是否启用');
$table->integer('sort_order')->default(0)->comment('排序,数字越小越靠前');
$table->timestamps();
$table->index(['location', 'is_active', 'sort_order']);
});
}
public function down(): void
{
Schema::dropIfExists('hero_slides');
}
};
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use Illuminate\Database\Seeder;
class AdminUserSeeder extends Seeder
{
public function run(): void
{
// 用 updateOrCreate 而非 firstOrCreate:若账号已存在(如早期测试注册过、
// 或旧版种子先建过且 role=user),仍需强制校正为超管并重置密码,避免「找到了就不更新」导致无后台权限。
User::updateOrCreate(
['email' => 'admin@cloud-chip.cn'],
[
'name' => '管理员',
'email' => 'admin@cloud-chip.cn',
'password' => 'cloudchip2026',
'is_admin' => true,
'role' => 'super_admin',
]
);
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
use App\Models\Article;
use App\Models\Category;
use Illuminate\Database\Seeder;
class ArticleSeeder extends Seeder
{
public function run(): void
{
$cat = Category::where('slug', 'design-guide')->first();
$items = [
[
'category_id' => $cat?->id,
'title' => '多口 PD 充电器设计要点:端口优先级与功率分配策略',
'slug' => 'multi-port-pd-design-guide',
'summary' => '本文介绍多口 PD 充电器中端口优先级判定、动态功率分配和热管理的设计要点。',
'body' => "## 端口优先级\n\n多口 PD 充电器需要根据接入设备类型和数量动态分配功率。常见策略包括:\n\n1. **均分策略**:各口平均分配总功率\n2. **优先级策略**:C1 口优先获得最大功率\n3. **自适应策略**:根据设备请求的 PD contract 动态调整\n\n## 功率分配\n\n以 CC-PD3168 为例,3 口总功率 100W\n- 单口接入时:C1/C2/C3 均可输出 100W (20V/5A)\n- 双口接入时:C1=65W, C2=30W\n- 三口接入时:C1=65W, C2=20W, C3=15W\n\n## 热管理\n\n多口同时工作时热量集中,需要合理的 PCB 布局和散热设计。",
'author' => '云创芯技术团队',
'status' => 'published',
'published_at' => now()->subDays(7),
],
[
'category_id' => $cat?->id,
'title' => 'USB PD3.X 协议解析:PPS 与 SPRS 模式',
'slug' => 'usb-pd3-pps-sprs-explained',
'summary' => '深入解析 USB PD3.X 中的 PPS(可编程电源)和 SPRS(系统电源参考)模式。',
'body' => "## PPS 模式\n\nPPSProgrammable Power Supply)允许电源在 3.3V 到 21V 之间以 20mV 步进调整输出电压,实现更精细的电压匹配。\n\n## SPRS 模式\n\nSPRSSystem Power Reference)是 PD3.X 中新增的参考电压机制,用于多设备系统级电源管理。\n\n## 应用场景\n\n- 笔记本快充:PPS 可降低转换损耗约 5%\n- 移动电源:SPRS 简化多设备充电管理",
'author' => '云创芯技术团队',
'status' => 'published',
'published_at' => now()->subDays(3),
],
];
foreach ($items as $item) {
Article::firstOrCreate(['slug' => $item['slug']], $item);
}
}
}
+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);
}
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call([
CategorySeeder::class,
ProductSeeder::class,
ArticleSeeder::class,
GlossaryTermSeeder::class,
ForumBoardSeeder::class,
AdminUserSeeder::class,
SettingsSeeder::class,
SolutionsSeeder::class,
NewsSeeder::class,
NavigationMenuSeeder::class,
HeroSlideSeeder::class,
PdContentSeeder::class, // 最后灌入真实 PD 内容(幂等,跨库安全)
]);
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace Database\Seeders;
use App\Models\ForumBoard;
use Illuminate\Database\Seeder;
class ForumBoardSeeder extends Seeder
{
public function run(): void
{
$boards = [
[
'name' => '选型咨询',
'slug' => 'selection',
'description' => '多口 TypeC 接口IC 选型、参数对比与技术方案讨论。',
'sort' => 1,
],
[
'name' => '调试与量产',
'slug' => 'debug',
'description' => 'PCB 布局、EMI 整改、量产测试经验分享。',
'sort' => 2,
],
[
'name' => '行业资讯',
'slug' => 'news',
'description' => 'TypeC 快速充电行业动态、标准更新与市场趋势。',
'sort' => 3,
],
];
foreach ($boards as $board) {
ForumBoard::firstOrCreate(['slug' => $board['slug']], $board);
}
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace Database\Seeders;
use App\Models\GlossaryTerm;
use Illuminate\Database\Seeder;
class GlossaryTermSeeder extends Seeder
{
public function run(): void
{
$terms = [
[
'term' => 'PD (Power Delivery)',
'slug' => 'pd-power-delivery',
'definition' => 'USB Power Delivery 协议,通过 USB-C 接口传输最高 240W (48V/5A) 的电力,支持双向供电和智能功率协商。',
'aliases' => 'USB PD, Power Delivery, 快充协议',
'category' => '协议',
],
[
'term' => 'PHY (物理层)',
'slug' => 'phy-physical-layer',
'definition' => 'PHY 是物理层(Physical Layer)的缩写,负责数据的物理传输,包括信号编码、调制解调、阻抗匹配等功能。',
'aliases' => 'Physical Layer, 物理层收发器',
'category' => '硬件',
],
[
'term' => 'PPS (可编程电源)',
'slug' => 'pps-programmable-power-supply',
'definition' => 'PPS 是 USB PD3.X 中的可编程电源模式,允许在 3.3V 到 21V 范围内以 20mV 步进调整输出电压,实现更高效的直充方案。',
'aliases' => 'Programmable Power Supply',
'category' => '协议',
],
[
'term' => 'BC1.2',
'slug' => 'bc1-2',
'definition' => 'Battery Charging Specification 1.2USB-IF 制定的电池充电规范,定义了 DCP(专用充电口)、CDP(充电下行口)和 SDP(标准下行口)三种充电模式。',
'aliases' => 'Battery Charging 1.2',
'category' => '协议',
],
[
'term' => '同步整流',
'slug' => 'synchronous-rectification',
'definition' => '同步整流是用 MOSFET 替代肖特基二极管进行整流的技术,可大幅降低整流损耗,提升转换效率至 95% 以上。',
'aliases' => 'Synchronous Rectification, SR',
'category' => '硬件',
],
];
foreach ($terms as $item) {
GlossaryTerm::firstOrCreate(['slug' => $item['slug']], $item);
}
}
}
+109
View File
@@ -0,0 +1,109 @@
<?php
namespace Database\Seeders;
use App\Models\HeroSlide;
use Illuminate\Database\Seeder;
class HeroSlideSeeder extends Seeder
{
/**
* 首页 Hero 轮播演示内容(富文本)。
*
* 内容均以「语义化 HTML + Quill 排版类(ql-*/ 自定义组件类(hero-*)」撰写,
* 与后台 Quill 编辑器真实产出一致,前台经 .rich-content 统一渲染。
*
* 部署演示轮播:先清空 hero_slides 再写入 3 条 demo,保证线上稳定展示这套轮播。
* 注意:会覆盖后台已配置的首页轮播内容;如需保留线上自定义轮播,请勿运行本 Seeder。
*/
public function run(): void
{
HeroSlide::query()->delete();
// ── 轮播 1:品牌主视觉(复刻原首页,含三栏能力卡)──
$slide1 = <<<HTML
<p class="hero-eyebrow">TypeC 产品顾问 · 多口 TypeC 接口IC 方案提供商</p>
<h1>为充电与外设厂商提供稳定、易集成的接口芯片</h1>
<p style="font-size:17px;color:rgba(255,255,255,0.88);">深圳市云创芯电子有限公司专注多口 TypeC 接口IC 与 PD 电源及其信号智能控制,支持标准 TypeC PD 协议(含快充、数据转换、功率智能分配),覆盖 PPS、SPRS 等快充协议,帮助客户缩短研发周期、提升量产良率。</p>
<div class="hero-feature-grid">
<div class="hero-feature-card">
<p class="hf-title">多协议覆盖</p>
<p class="hf-desc">PD3.X / PPS / SPRS 协议栈</p>
</div>
<div class="hero-feature-card">
<p class="hf-title">易集成</p>
<p class="hf-desc">标准化接口,缩短研发周期</p>
</div>
<div class="hero-feature-card">
<p class="hf-title">量产验证</p>
<p class="hf-desc">面向充电与外设厂商出货</p>
</div>
</div>
HTML;
// ── 轮播 2:产品矩阵(展示标题层级 + 行内高亮 + 列表 + 对齐)──
$slide2 = <<<HTML
<p class="hero-eyebrow">产品矩阵</p>
<h1>多口 TypeC 接口IC 全系选型</h1>
<p style="font-size:17px;color:rgba(255,255,255,0.88);">从单口到多口、从低压到百瓦级,覆盖主流快充场景的接口与协议控制芯片。</p>
<h3 style="color:#7dd3fc;">核心协议支持</h3>
<ul>
<li><strong>PD3.1 / PPS</strong>:宽范围电压调节,适配笔记本与移动设备</li>
<li><strong>SPR / EPR</strong>28V/140W 扩展功率范围</li>
<li><strong>数据角色切换</strong>DFP/UFP/DRP 自适应</li>
<li><strong>同步整流控制</strong>:高效率、低发热</li>
</ul>
<p class="ql-align-right" style="color:rgba(255,255,255,0.7);">— 面向充电、外设与工业客户出货</p>
HTML;
// ── 轮播 3:方案能力(展示超大标题 + 居中 + 提示框)──
$slide3 = <<<HTML
<p class="hero-eyebrow ql-align-center">参考设计</p>
<h1 class="ql-align-center ql-size-huge">30W140W 快充参考设计</h1>
<p class="ql-align-center" style="font-size:18px;color:rgba(255,255,255,0.88);">即拿即用的原理图、BOM 与调试指南,加速量产导入。</p>
<div class="hero-callout">
<p style="margin:0;color:#fff;"><strong>免费提供:</strong>选型手册、评估板与量产导入技术支持,由应用工程师一对一协助。</p>
</div>
HTML;
$slides = [
[
'location' => 'home',
'title' => '品牌主视觉',
'content' => $slide1,
'cta_text' => '获取选型支持',
'cta_url' => '/contact',
'cta2_text' => '浏览全部产品',
'cta2_url' => '/products',
'is_active' => true,
'sort_order' => 0,
],
[
'location' => 'home',
'title' => '产品矩阵',
'content' => $slide2,
'cta_text' => '查看产品中心',
'cta_url' => '/products',
'cta2_text' => '',
'cta2_url' => null,
'is_active' => true,
'sort_order' => 1,
],
[
'location' => 'home',
'title' => '方案能力',
'content' => $slide3,
'cta_text' => '下载参考设计',
'cta_url' => '/solutions',
'cta2_text' => '',
'cta2_url' => null,
'is_active' => true,
'sort_order' => 2,
],
];
foreach ($slides as $s) {
HeroSlide::create($s);
}
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace Database\Seeders;
use App\Models\NavigationMenu;
use Illuminate\Database\Seeder;
class NavigationMenuSeeder extends Seeder
{
/**
* 默认前台导航菜单(与改版前的顶部导航一致,含解决方案/新闻动态,
* 补全移动端此前遗漏的两项)。firstOrCreate 保证重复 seed 不覆盖后台改动。
*/
public function run(): void
{
$items = [
['label' => '首页', 'url' => '/', 'sort_order' => 0],
['label' => '关于我们', 'url' => '/about', 'sort_order' => 1],
['label' => '产品服务', 'url' => '/products', 'sort_order' => 2],
['label' => '解决方案', 'url' => '/solutions', 'sort_order' => 3],
['label' => '文章', 'url' => '/articles', 'sort_order' => 4],
['label' => '新闻动态', 'url' => '/news', 'sort_order' => 5],
['label' => '术语库', 'url' => '/glossary', 'sort_order' => 6],
['label' => '论坛', 'url' => '/forum', 'sort_order' => 7],
['label' => '联系我们', 'url' => '/contact', 'sort_order' => 8],
];
foreach ($items as $item) {
NavigationMenu::firstOrCreate(
['label' => $item['label'], 'url' => $item['url']],
['is_visible' => true, 'sort_order' => $item['sort_order']]
);
}
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
namespace Database\Seeders;
use App\Models\News;
use Illuminate\Database\Seeder;
/**
* 新闻动态示例数据:覆盖行业资讯 / 公司动态 / 展会活动 三类。
* 按 slug 幂等,可重复执行。品牌统一为「深圳市云创芯电子有限公司」。
*/
class NewsSeeder extends Seeder
{
public function run(): void
{
$items = [
[
'title' => 'USB-IF 发布新版 PD 规范,进一步统一快充生态',
'slug' => 'usb-if-new-pd-spec',
'category' => 'industry',
'summary' => 'USB-IF 近期更新 USB PD 规范,强化 EPR 与多设备供电能力,推动跨品牌快充兼容。',
'body' => "USB-IF 近期发布了 USB Power Delivery 规范的新一轮更新,进一步强化了 EPRExtended Power Range)与多设备协同供电能力。\n\n对于配件与品牌厂商而言,规范的统一意味着更高的互操作性与更低的适配成本。深圳市云创芯电子有限公司将持续跟进标准演进,并在方案库中同步可落地的参考设计。",
'status' => 'published',
'published_at' => now()->subDays(2),
],
[
'title' => '深圳市云创芯电子有限公司方案库上线 30W–140W 全功率段参考设计',
'slug' => 'pdtechhub-solution-library-launch',
'category' => 'company',
'summary' => '平台方案库正式上线,覆盖迷你充电、双口、桌面充电站到 140W 多设备方案。',
'body' => "深圳市云创芯电子有限公司方案库现已上线,首批提供 30W、65W、100W、140W 四档功率段的参考设计,覆盖充电器、桌面充电站等多类场景。\n\n每套方案均附带功率分配策略、关键器件选型与保护机制说明,帮助工程师更快完成产品定义与评估。",
'status' => 'published',
'published_at' => now()->subDays(5),
],
[
'title' => '深圳市云创芯电子有限公司受邀参加 2026 亚洲充电展,现场演示 140W 多口方案',
'slug' => 'pdtechhub-at-asia-charging-expo-2026',
'category' => 'event',
'summary' => '展会将集中展示 PD3.1 EPR 140W 多设备快充与氮化镓高集成方案。',
'body' => "深圳市云创芯电子有限公司将亮相 2026 亚洲充电展,现场演示基于 PD3.1 EPR 的 140W 多设备快充方案,以及 65W 双口氮化镓高集成设计。\n\n欢迎配件与品牌厂商的工程师莅临交流,了解最新方案库资源与对接合作机会。",
'status' => 'published',
'published_at' => now()->subDays(9),
],
[
'title' => '氮化镓(GaN)器件成本下探,百瓦快充加速普及',
'slug' => 'gan-cost-down-100w-fast-charging',
'category' => 'industry',
'summary' => '随着 GaN 器件规模量产,100W 级快充的 BOM 成本显著下降,普及拐点已至。',
'body' => "近年来氮化镓(GaN)功率器件在规模量产下成本持续下探,使得 65W–100W 级快充的整机 BOM 明显下降。\n\n成本门槛降低叠加用户对大功率快充的强劲需求,正推动百瓦快充从高端走向主流,为配件厂商带来新的产品机会。",
'status' => 'published',
'published_at' => now()->subDays(14),
],
[
'title' => '平台合作厂商突破 80 家,资源对接效率显著提升',
'slug' => 'pdtechhub-80-partners',
'category' => 'company',
'summary' => '深圳市云创芯电子有限公司资源对接网络持续扩大,芯片、模块与品牌厂商协作更高效。',
'body' => "截至本月,深圳市云创芯电子有限公司的合作网络已汇聚超过 80 家芯片、模块与品牌厂商。\n\n通过标准化的方案库与供需匹配,平台显著缩短了从选型到量产导入的沟通链路,更多合作案例正在落地。",
'status' => 'published',
'published_at' => now()->subDays(20),
],
];
foreach ($items as $item) {
News::firstOrCreate(['slug' => $item['slug']], $item);
}
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
/**
* PD 站点内容种子:把随包发布的真实内容(分类/产品/文章/术语)灌入数据库。
* 数据来源:database/seeders/data/site_content.json(由本地 MySQL 导出,含 20 篇 PD 技术文章 + 8 原创 + 10 转载 + 3 产品 + 5 术语 + 6 分类)。
*
* 设计要点:
* - 全部按 slug 幂等(已存在则跳过),可重复执行,不会覆盖用户后续新增/修改的内容。
* - 分类用「原 id -> 新 id」slug 映射,跨库部署 id 错位也无妨。
* - 文章作者统一关联到 admin@cloud-chip.cn 账户(author 文本字段仍保留原作者署名)。
*/
class PdContentSeeder extends Seeder
{
public function run(): void
{
$path = __DIR__ . '/data/site_content.json';
if (! file_exists($path)) {
return;
}
$data = json_decode(file_get_contents($path), true);
if (! is_array($data)) {
return;
}
// 1. 分类:按 slug 幂等,建立 原id -> 新id 映射(跨库 id 对齐)
$catMap = [];
foreach ($data['categories'] ?? [] as $c) {
$origId = $c['id'];
$existing = DB::table('categories')->where('slug', $c['slug'])->first();
if ($existing) {
$newId = $existing->id;
} else {
$row = $c;
unset($row['id']);
$newId = DB::table('categories')->insertGetId($row);
}
$catMap[$origId] = $newId;
}
// 文章作者关联到 admin 账户(若已存在)
$adminId = DB::table('users')->where('email', 'admin@cloud-chip.cn')->value('id');
// 2. 产品
foreach ($data['products'] ?? [] as $p) {
if (DB::table('products')->where('slug', $p['slug'])->exists()) {
continue;
}
if (! empty($p['category_id'])) {
$p['category_id'] = $catMap[$p['category_id']] ?? null;
}
DB::table('products')->insert($p);
}
// 3. 文章
foreach ($data['articles'] ?? [] as $a) {
if (DB::table('articles')->where('slug', $a['slug'])->exists()) {
continue;
}
if (! empty($a['category_id'])) {
$a['category_id'] = $catMap[$a['category_id']] ?? null;
}
$a['user_id'] = $adminId; // 弱关联;author 文本字段保留真实署名
DB::table('articles')->insert($a);
}
// 4. 术语库
foreach ($data['glossary_terms'] ?? [] as $g) {
if (DB::table('glossary_terms')->where('slug', $g['slug'])->exists()) {
continue;
}
DB::table('glossary_terms')->insert($g);
}
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Product;
use Illuminate\Database\Seeder;
class ProductSeeder extends Seeder
{
public function run(): void
{
$cat1 = Category::where('slug', 'pd-phy-controller')->first();
$cat2 = Category::where('slug', 'protocol-bridge')->first();
$cat3 = Category::where('slug', 'sync-rectifier')->first();
$items = [
[
'category_id' => $cat1?->id,
'name' => 'CC-PD3168 多口 PD 电源及其信号智能控制 IC',
'slug' => 'cc-pd3168',
'model' => 'CC-PD3168',
'summary' => '支持 3 口独立快充协商,内置 3168 协议栈,适用于桌面充与车充。',
'description' => "CC-PD3168 是一款面向多口充电器的 PD 电源及其信号智能控制芯片,支持 PD 3.0 及其以上的接口协议。\n\n主要特性:\n- 3 口独立 PD 协商\n- 内置 32-bit MCU\n- 支持 PPS / AVR / SPRS\n- 待机功耗低于 30mW\n- 封装 QFN-32",
'specs' => "接口: I2C / UART\n工作电压: 3.3V\n封装: QFN-32 (5x5mm)\n工作温度: -40~85C\n认证: USB-IF PD 3.0 Certified",
'status' => 'published',
'sort' => 1,
],
[
'category_id' => $cat2?->id,
'name' => 'CC-PT6540 PHY 接口协议转换 IC',
'slug' => 'cc-pt6540',
'model' => 'CC-PT6540',
'summary' => 'USB-C 到传统 PHY 接口桥接,向下兼容 BC1.2 与 Apple 2.4A。',
'description' => "CC-PT6540 提供 USB-C 到传统 PHY 接口的桥接功能,支持多种快充协议自动切换。\n\n主要特性:\n- USB-C DFP/DRP 角色\n- BC1.2 DCP/CDP/SDP 兼容\n- Apple 2.4A 兼容\n- 高电压耐受 28V",
'specs' => "接口: USB-C / D+/D-\n工作电压: 3.3V\n封装: QFN-24 (4x4mm)\n工作温度: -40~85C",
'status' => 'published',
'sort' => 2,
],
[
'category_id' => $cat3?->id,
'name' => 'CC-SC128 同步整流控制器',
'slug' => 'cc-sc128',
'model' => 'CC-SC128',
'summary' => '高效率同步整流,待机功耗低于 30mW,通过 CCC 认证。',
'description' => "CC-SC128 是一款高效率同步整流控制器,适用于反激式和正激式变换器的副边整流。\n\n主要特性:\n- 超低待机功耗 30mW\n- 自适应导通时间控制\n- 支持 CCM/DCM/QM 三种模式\n- 内置 80V MOSFET 驱动\n- CCC 认证通过",
'specs' => "驱动能力: 4A peak\n工作电压: 4.5~28V\n封装: SOP-8\n工作温度: -40~125C\n认证: CCC / CE / FCC",
'status' => 'published',
'sort' => 3,
],
];
foreach ($items as $item) {
Product::firstOrCreate(['slug' => $item['slug']], $item);
}
}
}
+50
View File
@@ -0,0 +1,50 @@
<?php
namespace Database\Seeders;
use App\Models\Setting;
use Illuminate\Database\Seeder;
class SettingsSeeder extends Seeder
{
/**
* 站点级默认配置:ICP 备案号、全局 SEO、Logo 等。
* 使用 firstOrCreate,重复 seed 不会覆盖管理员在后台的修改。
*/
public function run(): void
{
$defaults = [
'site_name' => ['value' => '深圳市云创芯电子有限公司', 'group' => 'general'],
'site_description' => [
'value' => '深圳市云创芯电子有限公司提供多口 TypeC 接口IC、协议转换与同步整流控制芯片,面向充电与外设厂商;支持标准的TypeC PD协议,包含快充、数据转换、功率智能分配。',
'group' => 'seo',
],
'seo_title_default' => ['value' => '深圳市云创芯电子有限公司 - 多口 TypeC 接口IC', 'group' => 'seo'],
'seo_description_default' => [
'value' => '深圳市云创芯电子有限公司提供多口 TypeC 接口IC、协议转换与同步整流控制芯片,面向充电与外设厂商;支持标准的TypeC PD协议,包含快充、数据转换、功率智能分配。',
'group' => 'seo',
],
'icp_no' => ['value' => '粤ICP备16118477号-2', 'group' => 'general'],
// 公安联网备案号(管局强制悬挂,与 ICP 并列)。由管理员在后台填写真实号。
'security_filing_no' => ['value' => '', 'group' => 'general'],
// 站内展示用横版 PNG(5KB,2x 高清屏适配),而非 123KB 的 ICO
'logo_url' => ['value' => '/images/logo-dark.png', 'group' => 'general'],
// 浏览器标签页图标用方形 ICO
'favicon_url' => ['value' => '/images/ccc-icon.ico', 'group' => 'general'],
'contact_email' => ['value' => 'contact@cloud-chip.cn', 'group' => 'general'],
// 前台主题配色(后台「站点设置」可切换):azure / slate / indigo / teal / amber
'theme' => ['value' => 'azure', 'group' => 'appearance'],
// 首页 Hero 显示模式:carousel(轮播)/ single(独立单图)
'hero_mode' => ['value' => 'carousel', 'group' => 'appearance'],
// 页脚富文本内容(后台「站点设置」用富文本编辑器维护,留空则不显示)
'footer_content' => ['value' => '', 'group' => 'general'],
];
foreach ($defaults as $key => $item) {
Setting::firstOrCreate(
['key' => $key],
['value' => $item['value'], 'group' => $item['group']]
);
}
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace Database\Seeders;
use App\Models\Solution;
use Illuminate\Database\Seeder;
/**
* PD 解决方案示例数据:覆盖 30W–140W 多功率段、充电/桌面等场景与不同芯片平台。
* 按 slug 幂等,可重复执行。
*/
class SolutionsSeeder extends Seeder
{
public function run(): void
{
$items = [
[
'name' => '30W GaN 迷你快充方案',
'slug' => '30w-gan-mini-charger',
'power_segment' => '30-65',
'application' => 'charger',
'chip_platform' => 'protocol',
'power' => '30W',
'summary' => '面向手机/小设备的单口氮化镓迷你充电方案,高集成、低温升,适合便携式配件。',
'advantages' => "高集成协议芯片,BOM 更精简\n氮化镓方案,体积较传统缩小约 45%\n全电压段效率 >92%,低温升",
'description' => "本方案基于高集成 USB PD 协议芯片,搭配氮化镓(GaN)功率器件,提供 30W20V/1.5A 或 15V/2A 等)单口输出。\n\n适用于手机、耳机、手表等小功率设备的便携快充配件,在保证功率密度的同时控制温升,便于通过各国安规与能效认证。",
'status' => 'published',
'sort' => 10,
],
[
'name' => '65W 双口氮化镓充电器方案',
'slug' => '65w-dual-port-gan',
'power_segment' => '30-65',
'application' => 'charger',
'chip_platform' => 'soc',
'power' => '65W',
'summary' => '双 Type-C 口动态功率分配方案,单口 65W、双口 45W+20W,适配笔电与手机同时快充。',
'advantages' => "双口动态功率分配,智能识别接入设备\n单芯片 SOC 方案,降低外围复杂度\n支持 PPS,兼容主流品牌快充协议",
'description' => "65W 双口氮化镓方案采用单芯片 SOC 架构,C1/C2 双 Type-C 口可动态分配功率:单口最高 65W20V/3.25A),双口 45W+20W。\n\n内置 PPS 支持,广泛兼容笔记本、平板与手机,适合多设备用户的桌面与差旅场景。",
'status' => 'published',
'sort' => 20,
],
[
'name' => '100W 三口桌面充电站方案',
'slug' => '100w-triple-port-dock',
'power_segment' => '65-100',
'application' => 'dock',
'chip_platform' => 'soc',
'power' => '100W',
'summary' => '三口(2C1A)桌面充电站参考设计,总功率 100W,为多设备办公桌提供一站式快充。',
'advantages' => "2C1A 三口,总功率 100W\n独立多路同步整流,端口互不干扰\n智能温控与过流保护,长时间满载稳定",
'description' => "100W 桌面充电站方案提供 2×Type-C + 1×USB-A 三口输出,总功率 100W,可同时为笔记本、手机与配件充电。\n\n采用多路独立同步整流与智能功率调度,配合完善的保护机制,适合办公桌、床头等固定场景的一站式充电需求。",
'status' => 'published',
'sort' => 30,
],
[
'name' => '140W 多设备快充方案',
'slug' => '140w-multi-device',
'power_segment' => 'gt100',
'application' => 'charger',
'chip_platform' => 'rectifier',
'power' => '140W',
'summary' => '面向高性能笔电与多设备的 140W28V/5A)PD3.1 EPR 方案,支持大电流同步整流。',
'advantages' => "支持 PD3.1 EPR 28V/5A 达 140W\n大电流同步整流,效率与温升兼优\n面向游戏本、工作站等高性能设备",
'description' => "140W 多设备方案基于 PD3.1 EPR 规范,支持 28V/5A 输出,可为高性能笔记本、移动工作站等大功耗设备供电。\n\n采用大电流同步整流平台,兼顾转换效率与温升控制,是高端快充与多设备供电场景的参考设计。",
'status' => 'published',
'sort' => 40,
],
];
foreach ($items as $item) {
Solution::firstOrCreate(['slug' => $item['slug']], $item);
}
}
}
File diff suppressed because one or more lines are too long