Files
boursecu_server/app/Console/Commands/SuperAdminProgramSettingsRefreshCommand.php
T
mohmdsdgandCursor 63195718a2 fix(settings): drop program-settings last-good cache and prefer montzar
Stale Redis overlay and SMS-origin-first fetch kept feature flags like customer_special_pricing false after SuperAdmin turned them on. Always fetch live and try adm.montzar.ir first.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 22:39:08 +03:30

46 lines
1.5 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Services\SuperAdminProgramSettingsOverlay;
use Illuminate\Console\Command;
class SuperAdminProgramSettingsRefreshCommand extends Command
{
protected $signature = 'superadmin:refresh-program-settings
{--clear-only : فقط memo درخواست را ریست کن (دیگر کش Redis نیست)}';
protected $description = 'تنظیمات دسترسی را دوباره از سوپرادمین می‌خواند (بدون کش)';
public function handle(): int
{
$overlay = app(SuperAdminProgramSettingsOverlay::class);
if ($this->option('clear-only')) {
$overlay->flushCache();
$this->line('cleared SuperAdmin program-settings request memo');
return self::SUCCESS;
}
$result = $overlay->refreshFromSuperAdmin();
if (! ($result['ok'] ?? false)) {
$this->error('fetch from SuperAdmin failed; next HTTP request will retry');
return self::FAILURE;
}
$items = is_array($result['items'] ?? null) ? $result['items'] : [];
$meta = is_array($result['meta'] ?? null) ? $result['meta'] : [];
$this->info('fetched '.(int) ($result['count'] ?? 0).' setting(s) from SuperAdmin');
if ($meta !== []) {
$this->line('meta: '.json_encode($meta, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
}
foreach ($items as $key => $value) {
$this->line(" {$key}={$value}");
}
return self::SUCCESS;
}
}