2015-11-26 18:45:04 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
|
|
class DummyContentSeeder extends Seeder
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the database seeds.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
2017-02-05 09:37:50 -05:00
|
|
|
$user = factory(\BookStack\User::class)->create();
|
2016-03-05 13:09:21 -05:00
|
|
|
$role = \BookStack\Role::getRole('editor');
|
2015-11-26 18:45:04 -05:00
|
|
|
$user->attachRole($role);
|
|
|
|
|
|
|
|
|
2017-03-26 14:24:57 -04:00
|
|
|
factory(\BookStack\Book::class, 20)->create(['created_by' => $user->id, 'updated_by' => $user->id])
|
2015-11-26 18:45:04 -05:00
|
|
|
->each(function($book) use ($user) {
|
2017-02-05 09:37:50 -05:00
|
|
|
$chapters = factory(\BookStack\Chapter::class, 5)->create(['created_by' => $user->id, 'updated_by' => $user->id])
|
2015-11-26 18:45:04 -05:00
|
|
|
->each(function($chapter) use ($user, $book){
|
2016-04-26 16:48:17 -04:00
|
|
|
$pages = factory(\BookStack\Page::class, 5)->make(['created_by' => $user->id, 'updated_by' => $user->id, 'book_id' => $book->id]);
|
2015-11-26 18:45:04 -05:00
|
|
|
$chapter->pages()->saveMany($pages);
|
|
|
|
});
|
2015-12-02 14:10:05 -05:00
|
|
|
$pages = factory(\BookStack\Page::class, 3)->make(['created_by' => $user->id, 'updated_by' => $user->id]);
|
2015-11-26 18:45:04 -05:00
|
|
|
$book->chapters()->saveMany($chapters);
|
2015-12-02 14:10:05 -05:00
|
|
|
$book->pages()->saveMany($pages);
|
2015-11-26 18:45:04 -05:00
|
|
|
});
|
2016-04-26 16:48:17 -04:00
|
|
|
|
2017-03-26 14:24:57 -04:00
|
|
|
app(\BookStack\Services\PermissionService::class)->buildJointPermissions();
|
|
|
|
app(\BookStack\Services\SearchService::class)->indexAllEntities();
|
2015-11-26 18:45:04 -05:00
|
|
|
}
|
|
|
|
}
|