Skip to content

Commit 33c649d

Browse files
committed
♻️ singleton registering
1 parent 0e62fa8 commit 33c649d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/helpers.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ function faker(string $locale = null) : \Xefi\Faker\Faker
1414

1515
$locale ??= 'en_US';
1616

17-
return app()->makeWith(\Xefi\Faker\Faker::class, compact('locale'));
17+
$abstract = \Xefi\Faker\Faker::class.':'.$locale;
18+
19+
if (! app()->bound($abstract)) {
20+
app()->singleton($abstract, fn () => new \Xefi\Faker\Faker($locale));
21+
}
22+
23+
return app()->make($abstract);
1824
}
19-
}
25+
}

0 commit comments

Comments
 (0)