fix(settings): keep local can_edit=0 keys in get_settings when SA omits them
Customer /api/get_settings dropped price_provider because SuperAdmin catalog did not return it. Merge SA values when present; otherwise keep the tenant copy so the app still receives the key. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -162,7 +162,7 @@ class SettingsController extends Controller
|
||||
private function composeSystemSettings($localRows)
|
||||
{
|
||||
$overlay = app(SuperAdminProgramSettingsOverlay::class);
|
||||
$saMap = $overlay->map();
|
||||
$saMap = $overlay->catalogMap();
|
||||
|
||||
$byKey = [];
|
||||
|
||||
@@ -177,7 +177,25 @@ class SettingsController extends Controller
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$byKey[(string) $key] = $this->overlayRowToSetting($item);
|
||||
$value = $item['value'] ?? null;
|
||||
if ($value !== null && $value !== '') {
|
||||
$byKey[(string) $key] = $this->overlayRowToSetting($item);
|
||||
}
|
||||
}
|
||||
foreach ($localRows as $row) {
|
||||
$key = (string) $row->key;
|
||||
if (isset($byKey[$key])) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (! $this->isEditableCanEdit($row->can_edit ?? null)) {
|
||||
$byKey[$key] = $row;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($localRows as $row) {
|
||||
@@ -219,14 +237,15 @@ class SettingsController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* get_settings: کلیدهای سوپرادمین (can_edit=0) + ردیفهای جدول لوکال با can_edit=1.
|
||||
* get_settings اپ/ادمین:
|
||||
* can_edit=1 (+ runtime) از DB لوکال
|
||||
* can_edit=0 از سوپرادمین؛ اگر کلید در SA نبود یا value خالی بود → کپی لوکال
|
||||
* اگر سوپرادمین در دسترس نباشد کل جدول لوکال برمیگردد.
|
||||
* کلیدهای runtime / متعلق به پنل خانگی همیشه از جدول لوکال میآیند.
|
||||
*/
|
||||
private function composeGetSettings($localRows)
|
||||
{
|
||||
$overlay = app(SuperAdminProgramSettingsOverlay::class);
|
||||
$saMap = $overlay->map();
|
||||
$saMap = $overlay->catalogMap();
|
||||
if ($saMap === null) {
|
||||
return $localRows;
|
||||
}
|
||||
@@ -234,8 +253,13 @@ class SettingsController extends Controller
|
||||
$byKey = [];
|
||||
|
||||
foreach ($localRows as $row) {
|
||||
if ($this->isEditableCanEdit($row->can_edit ?? null)) {
|
||||
$byKey[(string) $row->key] = $this->normalizeTenantOwnedRow($row);
|
||||
$key = (string) $row->key;
|
||||
if (
|
||||
$this->isEditableCanEdit($row->can_edit ?? null)
|
||||
|| SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|
||||
) {
|
||||
$byKey[$key] = $this->normalizeTenantOwnedRow($row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,22 +267,34 @@ class SettingsController extends Controller
|
||||
if (! is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
$key = (string) $key;
|
||||
if (
|
||||
SuperAdminProgramSettingsOverlay::isRuntime((string) $key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned((string) $key)
|
||||
SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$byKey[(string) $key] = $this->overlayRowToSetting($item);
|
||||
$value = $item['value'] ?? null;
|
||||
if ($value !== null && $value !== '') {
|
||||
$byKey[$key] = $this->overlayRowToSetting($item);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($localRows as $row) {
|
||||
$key = (string) $row->key;
|
||||
if (isset($byKey[$key])) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|
||||
) {
|
||||
$byKey[$key] = $this->normalizeTenantOwnedRow($row);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (! $this->isEditableCanEdit($row->can_edit ?? null)) {
|
||||
$byKey[$key] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user