Files
boursecu_server/app/Console/Commands/SuperAdminProgramSettingsRefreshCommand.php
T
mohmdsdgandCursor 995f6984ed feat(automations): add run-now test endpoint and sends log table
Enable immediate automation test runs without waiting for the scheduled hour, expose send history for debugging, and return all SuperAdmin overlay keys on refresh instead of only enable_automation.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 21:46:13 +03:30

42 lines
1.3 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 : فقط کش last-good را پاک کن}';
protected $description = 'کش overlay تنظیمات سوپرادمین را پاک/تازه می‌کند';
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;
}
$items = is_array($result['items'] ?? null) ? $result['items'] : [];
$this->info('fetched '.(int) ($result['count'] ?? 0).' setting(s) from SuperAdmin');
foreach ($items as $key => $value) {
$this->line(" {$key}={$value}");
}
return self::SUCCESS;
}
}