File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Faker \Generator ;
4
+ use Huntie \JsonApi \Tests \Fixtures \Models \Comment ;
5
+ use Huntie \JsonApi \Tests \Fixtures \Models \User ;
6
+
7
+ $ factory ->define (Comment::class, function (Generator $ faker ) {
8
+ return [
9
+ 'id ' => $ faker ->uuid ,
10
+ 'title ' => $ faker ->words (4 ),
11
+ 'content ' => $ faker ->paragraph (),
12
+ 'created_at ' => $ faker ->dateTime (),
13
+ ];
14
+ });
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Faker \Generator ;
4
+ use Huntie \JsonApi \Tests \Fixtures \Models \Post ;
5
+ use Huntie \JsonApi \Tests \Fixtures \Models \User ;
6
+
7
+ $ factory ->define (Post::class, function (Generator $ faker ) {
8
+ return [
9
+ 'id ' => $ faker ->uuid ,
10
+ 'title ' => $ faker ->words (4 ),
11
+ 'content ' => $ faker ->paragraphs (4 ),
12
+ 'created_at ' => $ faker ->dateTime (),
13
+ ];
14
+ });
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
use Faker \Generator ;
4
+ use Huntie \JsonApi \Tests \Fixtures \Models \Comment ;
5
+ use Huntie \JsonApi \Tests \Fixtures \Models \Post ;
4
6
use Huntie \JsonApi \Tests \Fixtures \Models \User ;
5
7
6
8
$ factory ->define (User::class, function (Generator $ faker ) {
7
9
return [
10
+ 'id ' => $ faker ->uuid ,
8
11
'name ' => $ faker ->name ,
9
12
'email ' => $ faker ->unique ()->safeEmail ,
10
13
'password ' => bcrypt ('password ' ),
11
14
];
12
15
});
16
+
17
+ $ factory ->state (User::class, 'withPosts ' , function (Generator $ faker ) {
18
+ return [
19
+ 'posts ' => factory (Post::class, 2 )->make (), // TODO see if $user->id is available
20
+ ];
21
+ });
22
+
23
+ $ factory ->state (User::class, 'withComments ' , function (Generator $ faker ) {
24
+ return [
25
+ 'comments ' => factory (Comment::class, 2 )->make (),
26
+ ];
27
+ });
You can’t perform that action at this time.
0 commit comments