搭建轻舟一期门户、后台和统一登录。

让分类、会员和示例工具共用同一账号,本地即可跑通登录与授权。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Dev
2026-11-09 16:46:35 +08:00
co-authored by Cursor
commit 60daff2365
173 changed files with 21585 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.sqlite*
@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('nickname', 40);
$table->string('password')->nullable();
$table->string('role', 20)->default('user')->index();
$table->string('status', 20)->default('active')->index();
$table->unsignedInteger('entitlement_version')->default(1);
$table->string('disabled_reason')->nullable();
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
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();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,358 @@
<?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('user_identities', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('type', 20);
$table->string('identifier', 191);
$table->dateTime('verified_at')->nullable();
$table->timestamps();
$table->unique(['type', 'identifier']);
});
Schema::create('verification_codes', function (Blueprint $table) {
$table->id();
$table->string('scene', 20);
$table->string('channel', 20);
$table->string('target', 191);
$table->string('code_hash', 64);
$table->dateTime('expires_at');
$table->dateTime('consumed_at')->nullable();
$table->string('ip', 45)->nullable();
$table->timestamps();
$table->index(['target', 'scene']);
});
Schema::create('user_sessions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('session_id', 191)->unique();
$table->string('ip', 45)->nullable();
$table->string('user_agent', 255)->nullable();
$table->dateTime('last_seen_at')->nullable();
$table->dateTime('revoked_at')->nullable();
$table->timestamps();
});
Schema::create('login_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('account', 191);
$table->string('method', 20);
$table->boolean('success')->default(false);
$table->string('ip', 45)->nullable();
$table->string('user_agent', 255)->nullable();
$table->string('message')->nullable();
$table->timestamps();
$table->index('created_at');
});
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->foreignId('parent_id')->nullable()->constrained('categories')->nullOnDelete();
$table->string('name', 80);
$table->string('slug', 80)->unique();
$table->string('icon', 40)->nullable();
$table->integer('sort')->default(0);
$table->boolean('show_in_nav')->default(true);
$table->string('status', 20)->default('published');
$table->timestamps();
});
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->string('name', 40);
$table->string('slug', 80)->unique();
$table->timestamps();
});
Schema::create('tools', function (Blueprint $table) {
$table->id();
$table->string('name', 80);
$table->string('slug', 80)->unique();
$table->string('icon', 255)->nullable();
$table->string('summary', 255);
$table->text('content')->nullable();
$table->string('type', 20);
$table->string('open_url', 500);
$table->string('language', 40)->nullable();
$table->text('internal_note')->nullable();
$table->string('badge', 20)->default('free');
$table->string('required_entitlement', 120)->nullable();
$table->integer('sort')->default(0);
$table->boolean('is_recommended')->default(false);
$table->string('status', 20)->default('draft');
$table->dateTime('published_at')->nullable();
$table->unsignedInteger('clicks')->default(0);
$table->timestamps();
$table->index('status');
});
Schema::create('category_tool', function (Blueprint $table) {
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
$table->foreignId('tool_id')->constrained()->cascadeOnDelete();
$table->primary(['category_id', 'tool_id']);
});
Schema::create('tool_tag', function (Blueprint $table) {
$table->foreignId('tool_id')->constrained()->cascadeOnDelete();
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->primary(['tool_id', 'tag_id']);
});
Schema::create('home_sections', function (Blueprint $table) {
$table->id();
$table->string('title', 80);
$table->string('slug', 80)->unique();
$table->integer('sort')->default(0);
$table->unsignedInteger('display_limit')->default(8);
$table->string('status', 20)->default('published');
$table->timestamps();
});
Schema::create('home_section_tool', function (Blueprint $table) {
$table->foreignId('home_section_id')->constrained()->cascadeOnDelete();
$table->foreignId('tool_id')->constrained()->cascadeOnDelete();
$table->integer('sort')->default(0);
$table->primary(['home_section_id', 'tool_id']);
});
Schema::create('banners', function (Blueprint $table) {
$table->id();
$table->string('title', 120);
$table->string('image', 500)->nullable();
$table->string('link', 500)->nullable();
$table->integer('sort')->default(0);
$table->dateTime('starts_at')->nullable();
$table->dateTime('ends_at')->nullable();
$table->string('status', 20)->default('published');
$table->timestamps();
});
Schema::create('navigations', function (Blueprint $table) {
$table->id();
$table->string('group_name', 20);
$table->string('title', 80);
$table->string('link', 500);
$table->integer('sort')->default(0);
$table->string('status', 20)->default('published');
$table->timestamps();
});
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->string('type', 20);
$table->string('title', 160);
$table->string('slug', 120)->unique();
$table->string('summary', 255)->nullable();
$table->text('body');
$table->string('status', 20)->default('draft');
$table->dateTime('published_at')->nullable();
$table->timestamps();
});
Schema::create('agreements', function (Blueprint $table) {
$table->id();
$table->string('type', 40)->unique();
$table->string('title', 120);
$table->text('body');
$table->timestamps();
});
Schema::create('plans', function (Blueprint $table) {
$table->id();
$table->string('code', 40)->unique();
$table->string('name', 80);
$table->unsignedInteger('price_cents')->default(0);
$table->string('period', 20)->default('month');
$table->string('description', 255)->nullable();
$table->integer('sort')->default(0);
$table->string('status', 20)->default('published');
$table->timestamps();
});
Schema::create('plan_entitlements', function (Blueprint $table) {
$table->id();
$table->foreignId('plan_id')->constrained()->cascadeOnDelete();
$table->string('entitlement_key', 120);
$table->string('entitlement_value', 120);
$table->timestamps();
$table->unique(['plan_id', 'entitlement_key']);
});
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
$table->foreignId('plan_id')->constrained()->restrictOnDelete();
$table->string('status', 20)->default('active');
$table->dateTime('starts_at');
$table->dateTime('ends_at');
$table->timestamps();
});
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->string('order_no', 40)->unique();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('type', 20);
$table->string('status', 20)->default('pending');
$table->unsignedInteger('amount_cents')->default(0);
$table->string('title', 160);
$table->string('remark')->nullable();
$table->dateTime('paid_at')->nullable();
$table->timestamps();
});
Schema::create('order_items', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->cascadeOnDelete();
$table->foreignId('plan_id')->nullable()->constrained()->nullOnDelete();
$table->string('title', 160);
$table->unsignedInteger('amount_cents')->default(0);
$table->timestamps();
});
Schema::create('service_tickets', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('tool_id')->nullable()->constrained()->nullOnDelete();
$table->string('contact', 120);
$table->text('requirement');
$table->unsignedInteger('quote_cents')->nullable();
$table->string('status', 20)->default('pending');
$table->text('delivery_note')->nullable();
$table->timestamps();
});
Schema::create('deployments', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('tool_id')->nullable()->constrained()->nullOnDelete();
$table->string('spec', 120)->nullable();
$table->string('access_url', 500)->nullable();
$table->string('status', 20)->default('pending');
$table->dateTime('ends_at')->nullable();
$table->string('remark')->nullable();
$table->timestamps();
});
Schema::create('oauth_clients', function (Blueprint $table) {
$table->id();
$table->string('name', 80);
$table->string('client_id', 80)->unique();
$table->string('secret_hash', 64)->nullable();
$table->json('redirect_uris');
$table->json('logout_uris')->nullable();
$table->foreignId('tool_id')->nullable()->constrained()->nullOnDelete();
$table->boolean('is_first_party')->default(true);
$table->boolean('is_public')->default(false);
$table->string('status', 20)->default('active');
$table->timestamps();
});
Schema::create('oauth_auth_codes', function (Blueprint $table) {
$table->id();
$table->string('code_hash', 64)->unique();
$table->foreignId('oauth_client_id')->constrained('oauth_clients')->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('redirect_uri', 500);
$table->json('scopes');
$table->string('nonce', 200)->nullable();
$table->string('code_challenge', 200);
$table->string('code_challenge_method', 10);
$table->dateTime('expires_at');
$table->dateTime('consumed_at')->nullable();
$table->timestamps();
});
Schema::create('oauth_access_tokens', function (Blueprint $table) {
$table->id();
$table->string('token_hash', 64)->unique();
$table->foreignId('oauth_client_id')->constrained('oauth_clients')->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->json('scopes');
$table->unsignedInteger('entitlement_version')->default(1);
$table->dateTime('expires_at');
$table->dateTime('revoked_at')->nullable();
$table->timestamps();
});
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
$table->id();
$table->string('token_hash', 64)->unique();
$table->foreignId('oauth_access_token_id')->constrained('oauth_access_tokens')->cascadeOnDelete();
$table->foreignId('oauth_client_id')->constrained('oauth_clients')->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->dateTime('expires_at');
$table->dateTime('revoked_at')->nullable();
$table->unsignedBigInteger('replaced_by_id')->nullable();
$table->timestamps();
});
Schema::create('audit_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('actor_id')->nullable()->constrained('users')->nullOnDelete();
$table->string('action', 80);
$table->string('subject_type', 120)->nullable();
$table->unsignedBigInteger('subject_id')->nullable();
$table->string('summary', 255);
$table->timestamps();
});
Schema::create('message_logs', function (Blueprint $table) {
$table->id();
$table->string('channel', 20);
$table->string('target_mask', 80);
$table->string('scene', 20);
$table->string('status', 20);
$table->string('error')->nullable();
$table->timestamps();
});
Schema::create('settings', function (Blueprint $table) {
$table->string('key', 100)->primary();
$table->text('value')->nullable();
$table->timestamps();
});
Schema::create('user_tool_opens', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('tool_id')->constrained()->cascadeOnDelete();
$table->unsignedInteger('open_count')->default(1);
$table->dateTime('last_opened_at');
$table->timestamps();
$table->unique(['user_id', 'tool_id']);
});
Schema::create('tool_open_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('tool_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->index('created_at');
});
}
public function down(): void
{
foreach ([
'tool_open_logs', 'user_tool_opens', 'settings', 'message_logs', 'audit_logs',
'oauth_refresh_tokens', 'oauth_access_tokens', 'oauth_auth_codes', 'oauth_clients',
'deployments', 'service_tickets', 'order_items', 'orders', 'subscriptions',
'plan_entitlements', 'plans', 'agreements', 'articles', 'navigations', 'banners',
'home_section_tool', 'home_sections', 'tool_tag', 'category_tool', 'tools', 'tags',
'categories', 'login_logs', 'user_sessions', 'verification_codes', 'user_identities',
] as $table) {
Schema::dropIfExists($table);
}
}
};
+164
View File
@@ -0,0 +1,164 @@
<?php
namespace Database\Seeders;
use App\Models\Agreement;
use App\Models\Article;
use App\Models\Category;
use App\Models\HomeSection;
use App\Models\Navigation;
use App\Models\OauthClient;
use App\Models\Plan;
use App\Models\Setting;
use App\Models\Tag;
use App\Models\Tool;
use App\Models\User;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
foreach ([
'site_name' => '轻舟',
'site_description' => '实用工具与软件服务平台',
'icp' => '',
'grace_days' => '3',
'sms_register_creates_user' => '1',
'mail_enabled' => '0',
] as $key => $value) {
Setting::query()->updateOrCreate(['key' => $key], ['value' => $value]);
}
$admin = User::query()->create([
'nickname' => '舟管',
'password' => 'Admin123456',
'role' => 'super_admin',
'status' => 'active',
]);
$admin->identities()->create(['type' => 'phone', 'identifier' => '13800138000', 'verified_at' => now()]);
$admin->identities()->create(['type' => 'email', 'identifier' => 'admin@qingzhou.local', 'verified_at' => now()]);
$user = User::query()->create([
'nickname' => '体验用户',
'password' => 'User123456',
'role' => 'user',
'status' => 'active',
]);
$user->identities()->create(['type' => 'phone', 'identifier' => '13900139000', 'verified_at' => now()]);
$user->identities()->create(['type' => 'email', 'identifier' => 'user@qingzhou.local', 'verified_at' => now()]);
$free = Plan::query()->create(['code' => 'free', 'name' => '免费', 'price_cents' => 0, 'period' => 'month', 'description' => '浏览平台并使用免费工具', 'sort' => 30, 'status' => 'published']);
$member = Plan::query()->create(['code' => 'member', 'name' => '会员', 'price_cents' => 2900, 'period' => 'month', 'description' => '解锁会员工具和更高额度', 'sort' => 20, 'status' => 'published']);
$enterprise = Plan::query()->create(['code' => 'enterprise', 'name' => '企业', 'price_cents' => 9900, 'period' => 'month', 'description' => '更高额度、优先支持和部署申请', 'sort' => 10, 'status' => 'published']);
$free->entitlements()->create(['entitlement_key' => 'tool:notes:access', 'entitlement_value' => 'true']);
foreach ([$member, $enterprise] as $plan) {
$plan->entitlements()->create(['entitlement_key' => 'tool:notes:access', 'entitlement_value' => 'true']);
$plan->entitlements()->create(['entitlement_key' => 'tool:convert:access', 'entitlement_value' => 'true']);
}
$member->entitlements()->create(['entitlement_key' => 'quota:convert:monthly', 'entitlement_value' => '200']);
$enterprise->entitlements()->create(['entitlement_key' => 'quota:convert:monthly', 'entitlement_value' => '2000']);
$enterprise->entitlements()->create(['entitlement_key' => 'support:priority', 'entitlement_value' => 'true']);
$enterprise->entitlements()->create(['entitlement_key' => 'deploy:instance', 'entitlement_value' => 'true']);
$office = Category::query()->create(['name' => '效率办公', 'slug' => 'office', 'icon' => '舟', 'sort' => 30, 'show_in_nav' => true, 'status' => 'published']);
$media = Category::query()->create(['name' => '多媒体', 'slug' => 'media', 'icon' => '声', 'sort' => 20, 'show_in_nav' => true, 'status' => 'published']);
$dev = Category::query()->create(['name' => '开发辅助', 'slug' => 'dev', 'icon' => '码', 'sort' => 10, 'show_in_nav' => true, 'status' => 'published']);
$docs = Category::query()->create(['parent_id' => $dev->id, 'name' => '文档', 'slug' => 'docs', 'icon' => '册', 'sort' => 5, 'show_in_nav' => true, 'status' => 'published']);
$tagNote = Tag::query()->create(['name' => '笔记', 'slug' => 'notes']);
$tagAi = Tag::query()->create(['name' => '文本', 'slug' => 'text']);
$tagDev = Tag::query()->create(['name' => '开发', 'slug' => 'dev']);
$notes = $this->tool('轻舟记事', 'notes', '记', '登录后就能用的示例记事工具,用来验证统一账号。', 'integrated', 'http://127.0.0.1:8090/notes', 'PHP', 'free', null, true, [$office->id], [$tagNote->id]);
$convert = $this->tool('轻舟转写', 'convert', '转', '会员可用的示例工具。未开通会员也能登录,付费功能会提示升级。', 'integrated', 'http://127.0.0.1:8090/convert', 'PHP', 'member', 'tool:convert:access', true, [$media->id], [$tagAi->id]);
$vue = $this->tool('Vue 文档', 'vue-docs', 'V', '收录链接,只统计点击,不共享登录状态。', 'link', 'https://cn.vuejs.org/', null, 'free', null, false, [$docs->id], [$tagDev->id]);
$laravel = $this->tool('Laravel 文档', 'laravel-docs', 'L', 'Laravel 框架文档。', 'link', 'https://laravel.com/docs/11.x', null, 'free', null, false, [$docs->id], [$tagDev->id]);
$element = $this->tool('Element Plus', 'element-plus', 'E', 'Vue 3 组件库文档。', 'link', 'https://element-plus.org/zh-CN/', null, 'free', null, true, [$docs->id], [$tagDev->id]);
$hot = HomeSection::query()->create(['title' => '热门推荐', 'slug' => 'hot', 'sort' => 30, 'display_limit' => 8, 'status' => 'published']);
$hot->tools()->sync([$notes->id => ['sort' => 0], $convert->id => ['sort' => 1], $element->id => ['sort' => 2]]);
$officeSection = HomeSection::query()->create(['title' => '效率办公', 'slug' => 'office', 'sort' => 20, 'display_limit' => 8, 'status' => 'published']);
$officeSection->tools()->sync([$notes->id => ['sort' => 0]]);
$devSection = HomeSection::query()->create(['title' => '开发辅助', 'slug' => 'dev', 'sort' => 10, 'display_limit' => 8, 'status' => 'published']);
$devSection->tools()->sync([$vue->id => ['sort' => 0], $laravel->id => ['sort' => 1], $element->id => ['sort' => 2]]);
$this->client('轻舟记事', 'qz_notes', 'demo-notes-secret', 'http://127.0.0.1:8090/callback/notes', $notes->id);
$this->client('轻舟转写', 'qz_convert', 'demo-convert-secret', 'http://127.0.0.1:8090/callback/convert', $convert->id);
Article::query()->create([
'type' => 'announcement',
'title' => '轻舟开始内测',
'slug' => 'welcome',
'summary' => '一次登录,即可在已接入的工具间共用账号和会员权益。',
'body' => '<p>轻舟把多个在线工具收进同一套账号。打开接入工具时不需要再次输入密码。</p>',
'status' => 'published',
'published_at' => now(),
]);
Article::query()->create([
'type' => 'help',
'title' => '如何登录',
'slug' => 'how-to-login',
'summary' => '可以使用手机验证码,或邮箱、手机号加密码。',
'body' => '<p>密码在浏览器里加密后再提交。本地调试时,短信验证码固定为 123456。</p>',
'status' => 'published',
'published_at' => now(),
]);
Article::query()->create([
'type' => 'help',
'title' => '会员如何生效',
'slug' => 'membership',
'summary' => '提交订单后,由运营确认收款并开通。',
'body' => '<p>登录和会员是两件事。没有会员也可以进入工具,付费功能会提示升级。</p>',
'status' => 'published',
'published_at' => now(),
]);
Agreement::query()->create(['type' => 'terms', 'title' => '用户协议', 'body' => '<p>使用轻舟即表示你同意遵守平台规则,并不把账号出借给他人。</p>']);
Agreement::query()->create(['type' => 'privacy', 'title' => '隐私政策', 'body' => '<p>手机号和邮箱只用于登录与安全通知。工具默认拿不到你的手机号。</p>']);
Navigation::query()->create(['group_name' => 'header', 'title' => '会员', 'link' => '/pricing', 'sort' => 20, 'status' => 'published']);
Navigation::query()->create(['group_name' => 'header', 'title' => '帮助', 'link' => '/help', 'sort' => 10, 'status' => 'published']);
Navigation::query()->create(['group_name' => 'footer', 'title' => '用户协议', 'link' => '/agreements/terms', 'sort' => 20, 'status' => 'published']);
Navigation::query()->create(['group_name' => 'footer', 'title' => '隐私政策', 'link' => '/agreements/privacy', 'sort' => 10, 'status' => 'published']);
}
private function tool(string $name, string $slug, string $icon, string $summary, string $type, string $url, ?string $language, string $badge, ?string $entitlement, bool $recommended, array $categories, array $tags): Tool
{
$tool = Tool::query()->create([
'name' => $name,
'slug' => $slug,
'icon' => $icon,
'summary' => $summary,
'content' => '<p>'.$summary.'</p>',
'type' => $type,
'open_url' => $url,
'language' => $language,
'badge' => $badge,
'required_entitlement' => $entitlement,
'sort' => 10,
'is_recommended' => $recommended,
'status' => 'published',
'published_at' => now(),
]);
$tool->categories()->sync($categories);
$tool->tags()->sync($tags);
return $tool;
}
private function client(string $name, string $clientId, string $secret, string $redirect, int $toolId): void
{
OauthClient::query()->create([
'name' => $name,
'client_id' => $clientId,
'secret_hash' => hash('sha256', $secret),
'redirect_uris' => [$redirect],
'logout_uris' => ['http://127.0.0.1:8090/backchannel'],
'tool_id' => $toolId,
'is_first_party' => true,
'is_public' => false,
'status' => 'active',
]);
}
}