- @if ($this->settingEnum)
+ @if ($this->inputField)
@endif
diff --git a/resources/views/pages/system/settings/⚡update-setting-modal/update-setting-modal.php b/resources/views/pages/system/settings/⚡update-setting-modal/update-setting-modal.php
index 070940b..b9fc3b2 100644
--- a/resources/views/pages/system/settings/⚡update-setting-modal/update-setting-modal.php
+++ b/resources/views/pages/system/settings/⚡update-setting-modal/update-setting-modal.php
@@ -6,6 +6,7 @@ use App\Domains\System\Enums\SystemSettingKey;
use App\Domains\System\Models\SystemSettings;
use App\Livewire\Concerns\WithModal;
use App\Livewire\Concerns\WithToast;
+use App\UI\Support\Schemas\InputSchemaField;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Locked;
use Livewire\Attributes\Validate;
@@ -19,7 +20,7 @@ new class extends Component
use WithToast;
#[Locked]
- public string $settingKey = '';
+ public ?SystemSettingKey $settingKey = null;
#[Validate]
public mixed $settingValue = null;
@@ -32,16 +33,16 @@ new class extends Component
public function rules(): array
{
return [
- 'settingValue' => $this->settingEnum->schema()->rules,
+ 'settingValue' => $this->inputField->rules,
];
}
public function show(int|string $id): void
{
- $this->settingKey = $id;
+ $this->settingKey = SystemSettingKey::tryFrom($id);
$setting = SystemSettings::where('key', $id)
->first();
- if ($this->settingEnum->schema()->type->isFile()) {
+ if ($this->inputField->type->isFile()) {
$this->settingValue = $setting->value;
} else {
$this->settingValue = $setting?->translated_value ?? '-';
@@ -49,9 +50,9 @@ new class extends Component
}
#[Computed]
- public function settingEnum(): ?SystemSettingKey
+ public function inputField(): ?InputSchemaField
{
- return SystemSettingKey::tryFrom($this->settingKey);
+ return $this->settingKey?->getSchema();
}
public function save(UpdateSettings $action): void
@@ -59,11 +60,11 @@ new class extends Component
$this->validate();
$action->execute(new SystemSetingDTO(
- key: $this->settingEnum,
+ key: $this->settingKey,
value: $this->settingValue,
));
- $this->success(__('ui/crud.success.updated', ['resource' => $this->settingEnum->label()]));
+ $this->success(__('ui/crud.success.updated', ['resource' => $this->settingKey->label()]));
$this->dispatch('hide-update-setting-modal');
$this->dispatch('setting-updated');
}