feat(server): overlay admin get_settings from SuperAdmin program-settings
Fetch public program-settings with 3-origin retry and no Laravel cache so local DB settings stay in sync with the sold version. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,6 +24,11 @@ class ConfigService
|
||||
*/
|
||||
public function get(string $key, $default = null)
|
||||
{
|
||||
$fromSa = $this->valueFromSuperAdmin($key, $default);
|
||||
if ($fromSa !== '__sa_miss__') {
|
||||
return $fromSa;
|
||||
}
|
||||
|
||||
try {
|
||||
$row = Setting::where('key', $key)->first();
|
||||
|
||||
@@ -39,6 +44,40 @@ class ConfigService
|
||||
return $fromFile !== null ? $fromFile : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* مقدار سوپرادمین اگر کلید در overlay باشد؛ وگرنه سنتنل miss.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function valueFromSuperAdmin(string $key, $default)
|
||||
{
|
||||
try {
|
||||
$row = app(SuperAdminProgramSettingsOverlay::class)->row($key);
|
||||
} catch (\Throwable $e) {
|
||||
return '__sa_miss__';
|
||||
}
|
||||
|
||||
if ($row === null) {
|
||||
return '__sa_miss__';
|
||||
}
|
||||
|
||||
$active = $row['is_active'] ?? 1;
|
||||
if ($active === 0 || $active === false || $active === '0') {
|
||||
$fromFile = config("price_providers.{$key}");
|
||||
|
||||
return $fromFile !== null ? $fromFile : $default;
|
||||
}
|
||||
|
||||
$value = $row['value'] ?? null;
|
||||
if ($value === null || $value === '') {
|
||||
$fromFile = config("price_providers.{$key}");
|
||||
|
||||
return $fromFile !== null ? $fromFile : $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getString(string $key, string $default = ''): string
|
||||
{
|
||||
$value = $this->get($key, $default);
|
||||
|
||||
Reference in New Issue
Block a user