File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -32,21 +32,33 @@ public function load(): static
3232 }
3333
3434 /**
35- * @param Collection<int, Setting> $settings
35+ * @param array<string, mixed>| Collection<int, Setting> $settings
3636 */
37- public function fill (Collection $ settings ): static
37+ public function fill (array | Collection $ settings ): static
3838 {
3939
40- $ namespace = $ this ->getNamespace ();
40+ if ($ settings instanceof Collection) {
41+ $ namespace = $ this ->getNamespace ();
4142
42- foreach (get_object_vars ($ this ) as $ name => $ value ) {
43+ foreach (get_object_vars ($ this ) as $ name => $ value ) {
44+
45+ $ setting = $ settings ->firstWhere (function ($ setting ) use ($ namespace , $ name ) {
46+ return $ setting ->namespace === $ namespace && $ setting ->name === $ name ;
47+ });
48+
49+ if ($ setting ) {
50+ $ this ->{$ name } = $ setting ->value ;
51+ }
52+
53+ }
54+ } else {
55+
56+ foreach ($ settings as $ key => $ value ) {
4357
44- $ setting = $ settings -> firstWhere ( function ( $ setting ) use ( $ namespace , $ name ) {
45- return $ setting -> namespace === $ namespace && $ setting -> name === $ name ;
46- });
58+ if ( property_exists ( static ::class , $ key ) ) {
59+ $ this ->{ $ key } = $ value ;
60+ }
4761
48- if ($ setting ) {
49- $ this ->{$ name } = $ setting ->value ;
5062 }
5163
5264 }
You can’t perform that action at this time.
0 commit comments