Add configurable system settings service

This commit is contained in:
Arya Dwi Putra
2025-12-01 07:38:04 +07:00
parent 03e9d968f5
commit 9aab35ff05
4 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Services\System;
use Illuminate\Support\Arr;
class SystemSettingService
{
/**
* Ambil semua konfigurasi sistem dengan struktur terkelompok.
*/
public function all(): array
{
return config('system', []);
}
/**
* Ambil satu nilai konfigurasi dengan dukungan dot notation.
*/
public function get(string $key, mixed $default = null): mixed
{
return Arr::get($this->all(), $key, $default);
}
/**
* Set konfigurasi secara runtime tanpa menyentuh database.
*/
public function set(string $key, mixed $value): void
{
$settings = $this->all();
Arr::set($settings, $key, $value);
config(['system' => $settings]);
}
}