2026-08-24 21:22:44 +03:30
|
|
|
<?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 : فقط کش last-good را پاک کن}';
|
|
|
|
|
|
2026-08-24 21:46:13 +03:30
|
|
|
protected $description = 'کش overlay تنظیمات سوپرادمین را پاک/تازه میکند';
|
2026-08-24 21:22:44 +03:30
|
|
|
|
|
|
|
|
public function handle(): int
|
|
|
|
|
{
|
|
|
|
|
$overlay = app(SuperAdminProgramSettingsOverlay::class);
|
|
|
|
|
|
|
|
|
|
if ($this->option('clear-only')) {
|
|
|
|
|
$overlay->flushCache();
|
|
|
|
|
$this->line('cleared SuperAdmin program-settings cache');
|
|
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = $overlay->refreshFromSuperAdmin();
|
|
|
|
|
if (! ($result['ok'] ?? false)) {
|
|
|
|
|
$this->error('fetch from SuperAdmin failed — cache cleared; next HTTP request will retry');
|
|
|
|
|
|
|
|
|
|
return self::FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-24 21:46:13 +03:30
|
|
|
$items = is_array($result['items'] ?? null) ? $result['items'] : [];
|
2026-08-24 21:22:44 +03:30
|
|
|
$this->info('fetched '.(int) ($result['count'] ?? 0).' setting(s) from SuperAdmin');
|
2026-08-24 21:46:13 +03:30
|
|
|
foreach ($items as $key => $value) {
|
|
|
|
|
$this->line(" {$key}={$value}");
|
2026-08-24 21:22:44 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
}
|