fix(settings): expose SuperAdmin feature flags to customer get_settings
Menu gates like enable_product_funds were missing from the public API, so the user app could not hide disabled features. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -56,9 +56,14 @@ class SettingsController extends Controller
|
|||||||
return response()->json([]);
|
return response()->json([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$clientFeatureKeys = SuperAdminProgramSettingsOverlay::CLIENT_FEATURE_KEYS;
|
||||||
|
|
||||||
$local = Setting::query()
|
$local = Setting::query()
|
||||||
->select(Setting::adminSelectColumns())
|
->select(Setting::adminSelectColumns())
|
||||||
->where('show_to_user', 1)
|
->where(function ($query) use ($clientFeatureKeys) {
|
||||||
|
$query->where('show_to_user', 1)
|
||||||
|
->orWhereIn('key', $clientFeatureKeys);
|
||||||
|
})
|
||||||
->orderBy('key')
|
->orderBy('key')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
@@ -407,6 +412,13 @@ class SettingsController extends Controller
|
|||||||
$setting->show_to_user = $local->show_to_user;
|
$setting->show_to_user = $local->show_to_user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// دسترسیهای منوی اپ کاربر همیشه به کلاینت میرسند (حتی اگر local show_to_user=0 یا absent)
|
||||||
|
if (
|
||||||
|
Setting::hasShowToUserColumn()
|
||||||
|
&& SuperAdminProgramSettingsOverlay::isClientFeatureKey((string) $setting->key)
|
||||||
|
) {
|
||||||
|
$setting->show_to_user = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $setting;
|
return $setting;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ class Setting extends Model
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (\App\Services\SuperAdminProgramSettingsOverlay::isClientFeatureKey($key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$flag = is_array($row) ? ($row['show_to_user'] ?? 0) : ($row->show_to_user ?? 0);
|
$flag = is_array($row) ? ($row['show_to_user'] ?? 0) : ($row->show_to_user ?? 0);
|
||||||
|
|
||||||
return $flag === true || $flag === 1 || $flag === '1';
|
return $flag === true || $flag === 1 || $flag === '1';
|
||||||
|
|||||||
@@ -39,6 +39,22 @@ class SuperAdminProgramSettingsOverlay
|
|||||||
'show_to_users_chat',
|
'show_to_users_chat',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* دسترسیهای سوپرادمین که منو/مسیر اپ کاربر را کنترل میکنند.
|
||||||
|
* باید همیشه در api/get_settings مشتری برسند (show_to_user).
|
||||||
|
*/
|
||||||
|
public const CLIENT_FEATURE_KEYS = [
|
||||||
|
'enable_conditional_order',
|
||||||
|
'enable_product_funds',
|
||||||
|
'has_page_earn_money',
|
||||||
|
'has_page_gift_card',
|
||||||
|
'has_page_notification',
|
||||||
|
'has_page_price_trigger',
|
||||||
|
'jibit_enabled',
|
||||||
|
'permision__enabled',
|
||||||
|
'show_to_users_chat',
|
||||||
|
];
|
||||||
|
|
||||||
/** کلیدهایی که هنوز صفحهٔ اختصاصی ادمین خانگی مالکشان است — از overlay دور انداخته میشوند */
|
/** کلیدهایی که هنوز صفحهٔ اختصاصی ادمین خانگی مالکشان است — از overlay دور انداخته میشوند */
|
||||||
public const LOCAL_OWNED_KEYS = [
|
public const LOCAL_OWNED_KEYS = [
|
||||||
'tracking_systems',
|
'tracking_systems',
|
||||||
@@ -291,4 +307,9 @@ class SuperAdminProgramSettingsOverlay
|
|||||||
{
|
{
|
||||||
return in_array(trim($key), self::SUPERADMIN_OWNED_KEYS, true);
|
return in_array(trim($key), self::SUPERADMIN_OWNED_KEYS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isClientFeatureKey(string $key): bool
|
||||||
|
{
|
||||||
|
return in_array(trim($key), self::CLIENT_FEATURE_KEYS, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ UPDATE `settings` SET `show_to_user` = 1 WHERE `key` IN (
|
|||||||
'fee_deduct_from_gold',
|
'fee_deduct_from_gold',
|
||||||
'fee_service_charge_percentage',
|
'fee_service_charge_percentage',
|
||||||
'has_chat',
|
'has_chat',
|
||||||
|
'has_page_earn_money',
|
||||||
'has_page_gift_card',
|
'has_page_gift_card',
|
||||||
'has_page_notification',
|
'has_page_notification',
|
||||||
'has_page_price_trigger',
|
'has_page_price_trigger',
|
||||||
|
|||||||
Reference in New Issue
Block a user