'datetime', 'valid_until' => 'datetime', 'revoked_at' => 'datetime', ]; } public function code(): BelongsTo { return $this->belongsTo(DiscountCode::class, 'discount_code_id'); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function grantor(): BelongsTo { return $this->belongsTo(User::class, 'granted_by'); } public function isActiveAt(CarbonInterface $now): bool { return $this->revoked_at === null && $this->granted_at->lessThanOrEqualTo($now) && ($this->valid_until === null || $this->valid_until->greaterThan($now)); } }