File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 13
13
14
14
class DatabaseServiceProvider extends ServiceProvider
15
15
{
16
+ /**
17
+ * The array of resolved Faker instances.
18
+ *
19
+ * @var array
20
+ */
21
+ protected static $ fakers = [];
22
+
16
23
/**
17
24
* Bootstrap the application events.
18
25
*
@@ -75,7 +82,13 @@ protected function registerConnectionServices()
75
82
protected function registerEloquentFactory ()
76
83
{
77
84
$ this ->app ->singleton (FakerGenerator::class, function ($ app , $ parameters ) {
78
- return FakerFactory::create ($ parameters ['locale ' ] ?? $ app ['config ' ]->get ('app.faker_locale ' , 'en_US ' ));
85
+ $ locale = $ parameters ['locale ' ] ?? $ app ['config ' ]->get ('app.faker_locale ' , 'en_US ' );
86
+
87
+ if (! isset (static ::$ fakers [$ locale ])) {
88
+ static ::$ fakers [$ locale ] = FakerFactory::create ($ locale );;
89
+ }
90
+
91
+ return static ::$ fakers [$ locale ];
79
92
});
80
93
81
94
$ this ->app ->singleton (EloquentFactory::class, function ($ app ) {
You can’t perform that action at this time.
0 commit comments