'integer', 'max_discount' => 'integer', 'min_order' => 'integer', 'usage_limit' => 'integer', 'per_customer_limit' => 'integer', 'product_types' => 'array', 'product_ids' => 'array', 'billing_cycles' => 'array', 'starts_at' => 'datetime', 'ends_at' => 'datetime', 'is_active' => 'boolean', ]; public static function normalizeCode(string $code): string { return strtoupper(trim($code)); } protected function code(): Attribute { return Attribute::set(fn (string $value) => self::normalizeCode($value)); } public function redemptions(): HasMany { return $this->hasMany(CouponRedemption::class); } public function activeRedemptions(): HasMany { return $this->redemptions()->whereNull('released_at'); } }