File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -19,18 +19,20 @@ trait ReplaceModelAttributes
19
19
{
20
20
public function replaceModelAttributes (string $ text , string $ replaceText , Model $ model )
21
21
{
22
- return preg_replace_callback ('/:: ' . $ replaceText . '::/ ' , function ($ match ) use ($ model ) {
22
+ return preg_replace_callback ('/:: ' . $ replaceText. '::/ ' , function ($ match ) use ($ model ) {
23
23
$ parts = collect (explode ('. ' , $ match [0 ] ?? '' ));
24
24
25
25
$ replace = $ parts ->reduce (function ($ value , $ part ) {
26
26
$ part = Str::between ($ part , ':: ' , ':: ' );
27
27
28
- return $ value ->$ part
29
- ?? $ value [$ part ]
30
- ?? '' ;
28
+ return $ value ->$ part ?? $ value [$ part ] ?? '' ;
31
29
}, $ model );
32
30
33
- return $ replace ?: $ match ;
31
+ if (is_array ($ replace )) {
32
+ return implode (', ' , $ replace );
33
+ }
34
+
35
+ return $ replace ?: $ match [0 ];
34
36
}, $ text );
35
37
}
36
38
}
You can’t perform that action at this time.
0 commit comments