Skip to content

Commit 63453a2

Browse files
committed
fix
1 parent b6b385f commit 63453a2

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/NamespacedSettings.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
use Elegantly\Settings\Facades\Settings;
88
use Elegantly\Settings\Models\Setting;
9+
use Illuminate\Contracts\Support\Arrayable;
910
use 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
}

0 commit comments

Comments
 (0)