init
This commit is contained in:
1
web10/database/.gitignore
vendored
Normal file
1
web10/database/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
44
web10/database/factories/UserFactory.php
Normal file
44
web10/database/factories/UserFactory.php
Normal file
@@ -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,32 @@
|
||||
<?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('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->string('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -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('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('parent_id')->nullable()->constrained('categories')->nullOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('icon')->nullable();
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->string('seo_title')->nullable();
|
||||
$table->string('seo_description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tags', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->unsignedInteger('hot_score')->default(0);
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->string('seo_title')->nullable();
|
||||
$table->string('seo_description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tags');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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('products', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('summary');
|
||||
$table->longText('description')->nullable();
|
||||
$table->string('cover')->nullable();
|
||||
$table->json('screenshots')->nullable();
|
||||
$table->string('video_url')->nullable();
|
||||
$table->string('website_url');
|
||||
$table->string('pricing_type')->nullable();
|
||||
$table->json('platforms')->nullable();
|
||||
$table->boolean('is_featured')->default(false);
|
||||
$table->dateTime('featured_until')->nullable();
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->unsignedInteger('hot_score')->default(0);
|
||||
$table->unsignedInteger('hot_override')->nullable();
|
||||
$table->unsignedInteger('view_count')->default(0);
|
||||
$table->unsignedInteger('click_count')->default(0);
|
||||
$table->string('status')->default('draft');
|
||||
$table->string('seo_title')->nullable();
|
||||
$table->string('seo_description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['category_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('products');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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('articles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('summary')->nullable();
|
||||
$table->longText('content_md');
|
||||
$table->string('cover')->nullable();
|
||||
$table->string('author')->nullable();
|
||||
$table->unsignedInteger('view_count')->default(0);
|
||||
$table->string('status')->default('draft');
|
||||
$table->dateTime('published_at')->nullable();
|
||||
$table->string('seo_title')->nullable();
|
||||
$table->string('seo_description')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['status', 'published_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('articles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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('comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('target_type');
|
||||
$table->unsignedBigInteger('target_id');
|
||||
$table->string('nickname');
|
||||
$table->string('email')->nullable();
|
||||
$table->text('content');
|
||||
$table->string('status')->default('pending');
|
||||
$table->unsignedInteger('like_count')->default(0);
|
||||
$table->text('reply_content')->nullable();
|
||||
$table->dateTime('replied_at')->nullable();
|
||||
$table->string('ip')->nullable();
|
||||
$table->string('user_agent')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['target_type', 'target_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('comments');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sensitive_words', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('word')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sensitive_words');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('site_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->text('value')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('site_settings');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('contact_messages', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->text('content');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contact_messages');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('content_view_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('content_type');
|
||||
$table->unsignedBigInteger('content_id');
|
||||
$table->string('ip');
|
||||
$table->string('user_agent_hash', 64);
|
||||
$table->date('viewed_on');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['content_type', 'content_id', 'ip', 'user_agent_hash', 'viewed_on'], 'content_view_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('content_view_logs');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('product_tag', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['product_id', 'tag_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('product_tag');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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('article_tag', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('article_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['article_id', 'tag_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('article_tag');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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::table('products', function (Blueprint $table) {
|
||||
$table->boolean('is_sponsored')->default(false)->after('is_featured');
|
||||
$table->dateTime('sponsor_until')->nullable()->after('featured_until');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn(['is_sponsored', 'sponsor_until']);
|
||||
});
|
||||
}
|
||||
};
|
||||
150
web10/database/seeders/CategorySeeder.php
Normal file
150
web10/database/seeders/CategorySeeder.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$categories = [
|
||||
[
|
||||
'name' => '写作与内容',
|
||||
'slug' => 'writing',
|
||||
'description' => 'AI 写作与内容生产工具',
|
||||
'children' => [
|
||||
['name' => 'AI 写作', 'slug' => 'ai-writing'],
|
||||
['name' => '改写润色', 'slug' => 'rewriting'],
|
||||
['name' => '摘要与笔记', 'slug' => 'summaries'],
|
||||
['name' => '文案营销', 'slug' => 'copywriting'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '设计与图像',
|
||||
'slug' => 'design',
|
||||
'description' => '视觉设计与图像处理',
|
||||
'children' => [
|
||||
['name' => '图像生成', 'slug' => 'image-generation'],
|
||||
['name' => '设计工具', 'slug' => 'design-tools'],
|
||||
['name' => '图像修复', 'slug' => 'image-restoration'],
|
||||
['name' => '背景去除', 'slug' => 'background-removal'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '视频与音频',
|
||||
'slug' => 'media',
|
||||
'description' => '视频与音频内容生产',
|
||||
'children' => [
|
||||
['name' => '视频生成', 'slug' => 'video-generation'],
|
||||
['name' => '视频剪辑', 'slug' => 'video-editing'],
|
||||
['name' => '配音合成', 'slug' => 'voice-over'],
|
||||
['name' => '音频转写', 'slug' => 'audio-transcription'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '编程与开发',
|
||||
'slug' => 'development',
|
||||
'description' => '面向开发者的 AI 工具',
|
||||
'children' => [
|
||||
['name' => '代码助手', 'slug' => 'code-assistant'],
|
||||
['name' => '低代码', 'slug' => 'low-code'],
|
||||
['name' => 'API 与平台', 'slug' => 'api-platforms'],
|
||||
['name' => '测试与调试', 'slug' => 'testing-debugging'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '办公与效率',
|
||||
'slug' => 'productivity',
|
||||
'description' => '日常办公与效率工具',
|
||||
'children' => [
|
||||
['name' => '日程与任务', 'slug' => 'tasks'],
|
||||
['name' => '文档协作', 'slug' => 'docs'],
|
||||
['name' => '会议助手', 'slug' => 'meetings'],
|
||||
['name' => '邮件助手', 'slug' => 'email'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '商业与营销',
|
||||
'slug' => 'business',
|
||||
'description' => '市场与业务增长',
|
||||
'children' => [
|
||||
['name' => '广告创意', 'slug' => 'ads'],
|
||||
['name' => 'SEO 与增长', 'slug' => 'seo-growth'],
|
||||
['name' => '电商运营', 'slug' => 'ecommerce'],
|
||||
['name' => '客户服务', 'slug' => 'customer-support'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '数据与研究',
|
||||
'slug' => 'research',
|
||||
'description' => '数据分析与研究工具',
|
||||
'children' => [
|
||||
['name' => '数据分析', 'slug' => 'data-analysis'],
|
||||
['name' => '可视化', 'slug' => 'visualization'],
|
||||
['name' => '搜索与洞察', 'slug' => 'insights'],
|
||||
['name' => '研究助手', 'slug' => 'research-assistant'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '教育与学习',
|
||||
'slug' => 'education',
|
||||
'description' => '学习与教育类工具',
|
||||
'children' => [
|
||||
['name' => '语言学习', 'slug' => 'language-learning'],
|
||||
['name' => '课程与题库', 'slug' => 'courses'],
|
||||
['name' => '学习助手', 'slug' => 'study-assistant'],
|
||||
['name' => '儿童教育', 'slug' => 'kids-education'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => '生产力工具',
|
||||
'slug' => 'automation',
|
||||
'description' => '自动化与工作流',
|
||||
'children' => [
|
||||
['name' => '自动化', 'slug' => 'automation-tools'],
|
||||
['name' => '代理与工作流', 'slug' => 'agents-workflows'],
|
||||
['name' => '集成工具', 'slug' => 'integrations'],
|
||||
['name' => '浏览器插件', 'slug' => 'browser-extensions'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'AI 平台与模型',
|
||||
'slug' => 'platforms',
|
||||
'description' => '模型平台与评测工具',
|
||||
'children' => [
|
||||
['name' => '模型平台', 'slug' => 'model-platforms'],
|
||||
['name' => '提示词工具', 'slug' => 'prompt-tools'],
|
||||
['name' => '训练与微调', 'slug' => 'finetuning'],
|
||||
['name' => '模型评测', 'slug' => 'model-evaluation'],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($categories as $index => $categoryData) {
|
||||
$parent = Category::updateOrCreate(
|
||||
['slug' => $categoryData['slug']],
|
||||
[
|
||||
'name' => $categoryData['name'],
|
||||
'description' => $categoryData['description'],
|
||||
'sort' => $index + 1,
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($categoryData['children'] as $childIndex => $child) {
|
||||
Category::updateOrCreate(
|
||||
['slug' => $child['slug']],
|
||||
[
|
||||
'name' => $child['name'],
|
||||
'parent_id' => $parent->id,
|
||||
'sort' => $childIndex + 1,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
web10/database/seeders/DatabaseSeeder.php
Normal file
20
web10/database/seeders/DatabaseSeeder.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
SiteSettingSeeder::class,
|
||||
CategorySeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
43
web10/database/seeders/SiteSettingSeeder.php
Normal file
43
web10/database/seeders/SiteSettingSeeder.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\SiteSetting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SiteSettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$settings = [
|
||||
'site_title' => 'AI 工具导航',
|
||||
'site_description' => '精选 AI 工具与产品导航',
|
||||
'about_content' => '我们专注于收录优质 AI 工具与产品,帮助用户快速找到合适的解决方案。',
|
||||
'site_footer' => '',
|
||||
'site_logo' => '',
|
||||
'home_featured_limit' => '8',
|
||||
'home_new_limit' => '8',
|
||||
'home_category_limit' => '20',
|
||||
'list_page_size' => '20',
|
||||
'list_more_threshold' => '20',
|
||||
'article_page_size' => '10',
|
||||
'comments_enabled' => '1',
|
||||
'show_sponsor_label' => '1',
|
||||
'hot_weight_view' => '1',
|
||||
'hot_weight_click' => '3',
|
||||
'ga_id' => '',
|
||||
'icp_number' => '',
|
||||
'social_links' => '',
|
||||
];
|
||||
|
||||
foreach ($settings as $key => $value) {
|
||||
SiteSetting::updateOrCreate(
|
||||
['key' => $key],
|
||||
['value' => $value]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user