path(), json_encode([ 'since' => time(), 'until' => time() + $maxSeconds, ])); } public function deactivate(): void { @unlink($this->path()); } public function isActive(): bool { if (! is_file($this->path())) { return false; } $data = json_decode((string) @file_get_contents($this->path()), true); $until = is_array($data) ? (int) ($data['until'] ?? 0) : 0; if ($until <= time()) { $this->deactivate(); return false; } return true; } public function retryAfter(): int { $data = json_decode((string) @file_get_contents($this->path()), true); $remaining = is_array($data) ? (int) ($data['until'] ?? 0) - time() : 0; return max(5, min(60, $remaining)); } private function path(): string { return $this->file ?? storage_path('.maintenance'); } }