File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change 66
77use Elegantly \Settings \Facades \Settings ;
88use Elegantly \Settings \Models \Setting ;
9+ use Illuminate \Contracts \Support \Arrayable ;
910use Illuminate \Database \Eloquent \Collection ;
1011
11- abstract class NamespacedSettings
12+ /**
13+ * @implements Arrayable<string, mixed>
14+ */
15+ abstract class NamespacedSettings implements Arrayable
1216{
1317 final public function __construct ()
1418 {
@@ -17,16 +21,14 @@ final public function __construct()
1721
1822 public static function get (): static
1923 {
20- return static :: make () ;
24+ return new static ;
2125 }
2226
2327 abstract public static function getNamespace (): string ;
2428
2529 public function load (): static
2630 {
27- return $ this ->fill (
28- Settings::only ($ this ->getNamespace ())
29- );
31+ return $ this ->fill (Settings::only ($ this ->getNamespace ()));
3032 }
3133
3234 /**
@@ -43,12 +45,10 @@ public function fill(Collection $settings): static
4345 return $ setting ->namespace === $ namespace && $ setting ->name === $ name ;
4446 });
4547
46- if (! $ setting ) {
47- continue ;
48+ if ($ setting ) {
49+ $ this ->{ $ name } = $ setting -> value ;
4850 }
4951
50- $ this ->{$ name } = $ setting ->value ;
51-
5252 }
5353
5454 return $ this ;
@@ -74,4 +74,12 @@ public function save(): static
7474 return $ this ;
7575
7676 }
77+
78+ /**
79+ * @return array<string, mixed>
80+ */
81+ public function toArray (): array
82+ {
83+ return get_object_vars ($ this );
84+ }
7785}
You can’t perform that action at this time.
0 commit comments