From 0c13ad1e64062f78b338d777b348f4a5bf7e8f1a Mon Sep 17 00:00:00 2001 From: Yutaka Kurosaki <> Date: Sun, 10 May 2026 12:45:06 +0900 Subject: [PATCH] Update DocumentSeeder to use DocumentService::createDocument Removes direct Document::create() calls that referenced the dropped title/content/rendered_html columns. Initial seed now creates the default-locale translation through the service. --- src/database/seeders/DocumentSeeder.php | 43 +++++++------------------ 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/src/database/seeders/DocumentSeeder.php b/src/database/seeders/DocumentSeeder.php index e7d3ca4..e986fda 100644 --- a/src/database/seeders/DocumentSeeder.php +++ b/src/database/seeders/DocumentSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use App\Models\Document; use Illuminate\Database\Seeder; class DocumentSeeder extends Seeder @@ -12,43 +11,23 @@ class DocumentSeeder extends Seeder */ public function run(): void { - // 既存のドキュメントがある場合はスキップ - if (Document::count() > 0) { + if (\App\Models\Document::count() > 0) { $this->command->info('Documents already exist. Skipping...'); return; } - $documents = [ - [ - 'title' => 'Home', - 'path' => 'Home.md', - 'slug' => 'home', - 'content' => $this->getHomeContent(), - ], - [ - 'title' => 'Getting Started', - 'path' => 'Getting Started.md', - 'slug' => 'getting-started', - 'content' => $this->getGettingStartedContent(), - ], - [ - 'title' => 'Markdown Guide', - 'path' => 'Markdown Guide.md', - 'slug' => 'markdown-guide', - 'content' => $this->getMarkdownGuideContent(), - ], + $service = app(\App\Services\DocumentService::class); + $defaultLocale = config('app.locale', 'en'); + + $docs = [ + ['title' => 'Home', 'content' => $this->getHomeContent()], + ['title' => 'Getting Started', 'content' => $this->getGettingStartedContent()], + ['title' => 'Markdown Guide', 'content' => $this->getMarkdownGuideContent()], ]; - foreach ($documents as $doc) { - Document::create([ - 'title' => $doc['title'], - 'path' => $doc['path'], - 'slug' => $doc['slug'], - 'content' => $doc['content'], - 'rendered_html' => Document::renderMarkdown($doc['content']), - ]); - - $this->command->info("Created: {$doc['title']}"); + foreach ($docs as $d) { + $service->createDocument($d['title'], $d['content'], null, $defaultLocale); + $this->command->info("Created: {$d['title']}"); } $this->command->info('Initial documents created successfully!');