syncDiscoveredPlugins(); try { $plugins->enable('larablog/ai-comment-moderation'); } catch (\Throwable) { // } try { $plugins->enable('larablog/payment'); $plugins->enable('larablog/membership'); } catch (\Throwable) { // } $admin = User::query() ->where('email', 'admin@larablog.test') ->orWhere('username', 'admin') ->first(); if ($admin === null) { $admin = User::query()->create([ 'email' => 'admin@larablog.test', 'name' => 'Admin', 'username' => 'admin', 'password' => 'password', ]); } else { $admin->forceFill([ 'email' => 'admin@larablog.test', 'name' => 'Admin', 'username' => 'admin', 'password' => 'password', ])->save(); } $admin->assignRole('admin'); $category = Category::query()->updateOrCreate( ['id' => 1], [ 'name' => '随笔', 'display_order' => 0, 'articles_count' => 2, 'description' => '随手记下的阅读与技术笔记。', 'intro' => '这里收录日常随笔:产品、写作与站点搭建过程中的短文。', 'keywords' => '随笔,博客,笔记', ] ); $html = Article::query()->updateOrCreate( ['id' => 1], [ 'category_id' => $category->id, 'user_id' => $admin->id, 'title' => '欢迎使用 LaraBlog(HTML 样例)', 'content' => '
这是一篇 HTML 正文,来自旧站风格。
你可以在后台切换主题、启停插件,并用 Markdown 继续写作。
', 'content_format' => ContentFormat::HTML, 'description' => 'HTML 格式演示', 'published_at' => now()->subDay(), 'visible' => true, 'stick' => true, ] ); $md = Article::query()->updateOrCreate( ['id' => 2], [ 'category_id' => $category->id, 'user_id' => $admin->id, 'title' => 'Markdown 才是未来', 'content' => "# Hello Markdown\n\n这是 **Markdown** 正文。\n\n- 主题可切换\n- 插件可启停\n- SEO / llms.txt 已就绪\n", 'content_format' => ContentFormat::MARKDOWN, 'description' => 'Markdown 格式演示', 'published_at' => now(), 'visible' => true, ] ); $tag = Tag::query()->updateOrCreate(['name' => 'larablog'], ['use_count' => 2]); $tag->articles()->syncWithoutDetaching([$html->id, $md->id]); Comment::query()->updateOrCreate( ['id' => 1], [ 'article_id' => $md->id, 'author' => '访客', 'content' => '看起来不错', 'moderation_status' => Comment::STATUS_APPROVED, 'published_at' => now(), ] ); Link::query()->updateOrCreate( ['id' => 1], [ 'name' => 'Laravel', 'url' => 'https://laravel.com', 'note' => 'PHP 框架', 'visible' => true, ] ); Stylevar::query()->updateOrCreate( ['id' => 1], [ 'title' => 'sidebar_note', 'value' => 'LaraBlog · 现代博客引擎', 'visible' => true, ] ); } }