File tree 1 file changed +15
-10
lines changed
1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -111,8 +111,8 @@ public function getCountries(
111
111
if ($ code && is_string ($ code )) {
112
112
$ code = [$ code ];
113
113
}
114
+ $ countries = [];
114
115
if ($ code && is_array ($ code )) {
115
- $ countries = [];
116
116
foreach ($ code as $ country_code ) {
117
117
if (array_key_exists ($ country_code , $ this ->countries )) {
118
118
$ copy = new \ArrayObject ($ this ->countries [$ country_code ]);
@@ -121,20 +121,25 @@ public function getCountries(
121
121
if ($ translate && $ this ->locale ) {
122
122
$ country ['name ' ] = $ this ->getTranslation ($ country ['name ' ], 'country ' );
123
123
}
124
- if ($ with_states ) {
125
- $ country ['states ' ] = $ this ->getStates (
126
- country_code: $ country_code ,
127
- translate: $ translate
128
- );
129
- }
130
- $ countries [$ country_code ] = (object ) $ country ;
124
+ $ countries [$ country_code ] = $ country ;
131
125
}
132
126
}
127
+ } else {
128
+ $ copy = new \ArrayObject ($ this ->countries );
129
+ $ countries = $ copy ->getArrayCopy ();
130
+ unset($ copy );
131
+ }
133
132
134
- return collect ($ countries );
133
+ if ($ with_states ) {
134
+ foreach ($ countries as $ country_code => $ country ) {
135
+ $ countries [$ country_code ]['states ' ] = $ this ->getStates (
136
+ country_code: $ country_code ,
137
+ translate: $ translate
138
+ );
139
+ }
135
140
}
136
141
137
- return collect ($ this -> countries );
142
+ return collect ($ countries );
138
143
}
139
144
140
145
public function getStates (
You can’t perform that action at this time.
0 commit comments