]> BookStack Code Mirror - bookstack/blob - database/factories/ModelFactory.php
Filtered scripts in custom HTML head for exports
[bookstack] / database / factories / ModelFactory.php
1 <?php
2
3 /*
4 |--------------------------------------------------------------------------
5 | Model Factories
6 |--------------------------------------------------------------------------
7 |
8 | Here you may define all of your model factories. Model factories give
9 | you a convenient way to create models for testing and seeding your
10 | database. Just tell the factory how a default model should look.
11 |
12 */
13
14 $factory->define(\BookStack\Auth\User::class, function ($faker) {
15     $name = $faker->name;
16     return [
17         'name' => $name,
18         'email' => $faker->email,
19         'slug' => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
20         'password' => Str::random(10),
21         'remember_token' => Str::random(10),
22         'email_confirmed' => 1
23     ];
24 });
25
26 $factory->define(\BookStack\Entities\Models\Bookshelf::class, function ($faker) {
27     return [
28         'name' => $faker->sentence,
29         'slug' => Str::random(10),
30         'description' => $faker->paragraph
31     ];
32 });
33
34 $factory->define(\BookStack\Entities\Models\Book::class, function ($faker) {
35     return [
36         'name' => $faker->sentence,
37         'slug' => Str::random(10),
38         'description' => $faker->paragraph
39     ];
40 });
41
42 $factory->define(\BookStack\Entities\Models\Chapter::class, function ($faker) {
43     return [
44         'name' => $faker->sentence,
45         'slug' => Str::random(10),
46         'description' => $faker->paragraph
47     ];
48 });
49
50 $factory->define(\BookStack\Entities\Models\Page::class, function ($faker) {
51     $html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
52     return [
53         'name' => $faker->sentence,
54         'slug' => Str::random(10),
55         'html' => $html,
56         'text' => strip_tags($html),
57         'revision_count' => 1
58     ];
59 });
60
61 $factory->define(\BookStack\Auth\Role::class, function ($faker) {
62     return [
63         'display_name' => $faker->sentence(3),
64         'description' => $faker->sentence(10)
65     ];
66 });
67
68 $factory->define(\BookStack\Actions\Tag::class, function ($faker) {
69     return [
70         'name' => $faker->city,
71         'value' => $faker->sentence(3)
72     ];
73 });
74
75 $factory->define(\BookStack\Uploads\Image::class, function ($faker) {
76     return [
77         'name' => $faker->slug . '.jpg',
78         'url' => $faker->url,
79         'path' => $faker->url,
80         'type' => 'gallery',
81         'uploaded_to' => 0
82     ];
83 });
84
85 $factory->define(\BookStack\Actions\Comment::class, function($faker) {
86     $text = $faker->paragraph(1);
87     $html = '<p>' . $text. '</p>';
88     return [
89         'html' => $html,
90         'text' => $text,
91         'parent_id' => null
92     ];
93 });