File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace LaraCore \Database \Factories ;
4
+
5
+ use LaraCore \App \Models \Users ;
6
+ use LaraCore \Framework \Factories \Factory ;
7
+
8
+ class UserFactory extends Factory
9
+ {
10
+ public function definition ()
11
+ {
12
+ $ quizJson = file_get_contents (base_path ('quiz.json ' ));
13
+ $ quiz = json_decode ($ quizJson , true );
14
+ return [
15
+ 'questions ' => json_encode ($ quiz [2 ])
16
+ ];
17
+ }
18
+
19
+ public function create ()
20
+ {
21
+ $ data = $ this ->definition ();
22
+ $ this ->make (Users::class, $ data );
23
+ }
24
+ public static function new ()
25
+ {
26
+ return new static ;
27
+ }
28
+
29
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace LaraCore \Database \Seeders ;
4
+
5
+ use LaraCore \Framework \Seeders \Seeder ;
6
+
7
+ class DatabaseSeeder extends Seeder
8
+ {
9
+ public function run ()
10
+ {
11
+ $ this ->callMany ([
12
+ UserSeeder::class,
13
+ // SubmissionSeeder::class
14
+ ]);
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace LaraCore \Database \Seeders ;
4
+
5
+ use LaraCore \Database \Factories \UserFactory ;
6
+ use LaraCore \Framework \Seeders \Seeder ;
7
+
8
+ class UserSeeder extends Seeder
9
+ {
10
+ public function run ()
11
+ {
12
+ // call the UserFactory to create a quiz
13
+ UserFactory::new ()->create ();
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments