'decimal:2', 'start_at' => 'datetime', 'end_at' => 'datetime', ]; } // ── Helpers ────────────────────────────────────────── public function isValid(): bool { $now = now(); if ($this->start_at && $now->lt($this->start_at)) return false; if ($this->end_at && $now->gt($this->end_at)) return false; if ($this->usage_limit !== null && $this->used_count >= $this->usage_limit) return false; return true; } public function applyDiscount(float $subtotal): float { if (!$this->isValid()) return 0; if ($this->type === 'percent') { return round($subtotal * ($this->value / 100), 2); } return min($this->value, $subtotal); } }