This repository was archived by the owner on Apr 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ public function generate($name)
71
71
72
72
$ this ->addWelcomeViewFile ($ path );
73
73
74
+ $ this ->addModelFactory ($ path );
75
+
74
76
return new Service (
75
77
$ name ,
76
78
$ slug ,
@@ -198,4 +200,17 @@ protected function getStub()
198
200
{
199
201
return __DIR__ .'/stubs/service.stub ' ;
200
202
}
203
+
204
+ /**
205
+ * Add the ModelFactory file.
206
+ *
207
+ * @param string $path
208
+ */
209
+ public function addModelFactory ($ path )
210
+ {
211
+ $ modelFactory = file_get_contents (__DIR__ . '/stubs/model-factory.stub ' );
212
+ $ this ->createFile ($ path . '/database/factories/ModelFactory.php ' , $ modelFactory );
213
+
214
+ unset($ modelFactory );
215
+ }
201
216
}
Original file line number Diff line number Diff line change
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('User namespace here', function (Faker\Generator $faker) {
15
+ /**
16
+ * @var string
17
+ */
18
+ static $password;
19
+
20
+ return [
21
+ 'name' => $faker->name,
22
+ 'email' => $faker->safeEmail,
23
+ 'password' => $password ?: $password = bcrypt('secret'),
24
+ 'remember_token' => str_random(10)
25
+ ];
26
+ });
You can’t perform that action at this time.
0 commit comments