#47 - Adding comments to the dummy content seeder.

This commit is contained in:
Abijeet 2017-06-11 11:40:37 +05:30
parent 8dab31b87a
commit 9dbd7fa618
2 changed files with 14 additions and 1 deletions

View File

@ -70,4 +70,14 @@ $factory->define(BookStack\Image::class, function ($faker) {
'type' => 'gallery',
'uploaded_to' => 0
];
});
$factory->define(BookStack\Comment::class, function($faker) {
$text = $faker->paragraph(3);
$html = '<p>' . $text. '</p>';
return [
'html' => $html,
'text' => '#' . $text,
'active' => 1
];
});

View File

@ -20,7 +20,10 @@ class DummyContentSeeder extends Seeder
->each(function($book) use ($user) {
$chapters = factory(\BookStack\Chapter::class, 5)->create(['created_by' => $user->id, 'updated_by' => $user->id])
->each(function($chapter) use ($user, $book){
$pages = factory(\BookStack\Page::class, 5)->make(['created_by' => $user->id, 'updated_by' => $user->id, 'book_id' => $book->id]);
$pages = factory(\BookStack\Page::class, 5)->create(['created_by' => $user->id, 'updated_by' => $user->id, 'book_id' => $book->id])->each(function($page) use ($user) {
$comments = factory(\BookStack\Comment::class, 3)->make(['created_by' => $user->id, 'updated_by' => $user->id, 'page_id' => $page->id]);
$page->comments()->saveMany($comments);
});
$chapter->pages()->saveMany($pages);
});
$pages = factory(\BookStack\Page::class, 3)->make(['created_by' => $user->id, 'updated_by' => $user->id]);