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
1919{
2020 public function replaceModelAttributes (string $ text , string $ replaceText , Model $ model )
2121 {
22- return preg_replace_callback ('/:: ' . $ replaceText . '::/ ' , function ($ match ) use ($ model ) {
22+ return preg_replace_callback ('/:: ' . $ replaceText. '::/ ' , function ($ match ) use ($ model ) {
2323 $ parts = collect (explode ('. ' , $ match [0 ] ?? '' ));
2424
2525 $ replace = $ parts ->reduce (function ($ value , $ part ) {
2626 $ part = Str::between ($ part , ':: ' , ':: ' );
2727
28- return $ value ->$ part
29- ?? $ value [$ part ]
30- ?? '' ;
28+ return $ value ->$ part ?? $ value [$ part ] ?? '' ;
3129 }, $ model );
3230
33- return $ replace ?: $ match ;
31+ if (is_array ($ replace )) {
32+ return implode (', ' , $ replace );
33+ }
34+
35+ return $ replace ?: $ match [0 ];
3436 }, $ text );
3537 }
3638}
You can’t perform that action at this time.
0 commit comments