From 8e5732d8576a8dd7a28d860b8d080bb195fa4c8d Mon Sep 17 00:00:00 2001 From: xboard Date: Fri, 7 Feb 2025 22:55:45 +0800 Subject: [PATCH] fix: coupon period limit --- app/Http/Resources/CouponResource.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/Http/Resources/CouponResource.php b/app/Http/Resources/CouponResource.php index b0fc77e..049a61f 100644 --- a/app/Http/Resources/CouponResource.php +++ b/app/Http/Resources/CouponResource.php @@ -25,20 +25,14 @@ class CouponResource extends JsonResource { return [ ...$this->resource->toArray(), - 'limit_plan_ids' => $this->when( - !empty($this->limit_plan_ids), - fn() => collect($this->limit_plan_ids) - ->map(fn(mixed $id): string => (string) $id) - ->values() - ->all() - ), - 'limit_period' => $this->when( - !empty($this->limit_period), - fn() => collect($this->limit_period) - ->map(fn(mixed $period): string => (string) PlanService::convertToLegacyPeriod($period)) - ->values() - ->all() - ) + 'limit_plan_ids' => empty($this->limit_plan_ids) ? null : collect($this->limit_plan_ids) + ->map(fn(mixed $id): string => (string) $id) + ->values() + ->all(), + 'limit_period' => empty($this->limit_period) ? null : collect($this->limit_period) + ->map(fn(mixed $period): string => (string) PlanService::convertToLegacyPeriod($period)) + ->values() + ->all(), ]; } }