@@ -34,7 +34,7 @@ public function boot()
34
34
*/
35
35
private function registerTranslationRepository ()
36
36
{
37
- $ this ->app ->singleton (TranslationRepository::class, function ($ app ) {
37
+ $ this ->app ->scoped (TranslationRepository::class, function ($ app ) {
38
38
$ model = $ app ['config ' ]->get ('localisation.model ' );
39
39
40
40
return new EloquentTranslationRepository (new $ model );
@@ -47,7 +47,7 @@ private function registerTranslationRepository()
47
47
*/
48
48
private function registerModelTransformer ()
49
49
{
50
- $ this ->app ->singleton (ModelTransformer::class, function ($ app ) {
50
+ $ this ->app ->scoped (ModelTransformer::class, function ($ app ) {
51
51
$ modelTransformer = new ModelTransformer ;
52
52
$ modelTransformer ->setTranslationRepository ($ app ->make (TranslationRepository::class));
53
53
@@ -61,7 +61,7 @@ private function registerModelTransformer()
61
61
*/
62
62
private function registerCollectionTransformer ()
63
63
{
64
- $ this ->app ->singleton (CollectionTransformer::class, function ($ app ) {
64
+ $ this ->app ->scoped (CollectionTransformer::class, function ($ app ) {
65
65
$ collectionTransformer = new CollectionTransformer ;
66
66
$ collectionTransformer ->setTranslationRepository ($ app ->make (TranslationRepository::class));
67
67
@@ -74,13 +74,17 @@ private function registerCollectionTransformer()
74
74
*/
75
75
private function registerTranslator ()
76
76
{
77
- $ this ->app ->singleton ('localisation.translator ' , function ($ app ) {
77
+ $ this ->app ->scoped ('localisation.translator ' , function ($ app ) {
78
78
$ translatorEngine = new Engine ;
79
-
79
+
80
80
$ translatorEngine ->registerTransformer (
81
81
$ app ->make (ModelTransformer::class),
82
82
$ app ->make (CollectionTransformer::class),
83
- $ app ->make (PaginationTransformer::class)
83
+ $ app ->make (PaginationTransformer::class),
84
+ ...array_map (
85
+ fn ($ transformer ) => $ app ->make ($ transformer ),
86
+ $ app ['config ' ]->get ('localisation.transformers ' , [])
87
+ )
84
88
);
85
89
86
90
return $ translatorEngine ;
0 commit comments