fix: coupon period limit

This commit is contained in:
xboard 2025-02-07 22:39:31 +08:00
parent b3339f7fe0
commit 2fb6691ca6

View File

@ -2,6 +2,9 @@
namespace App\Http\Resources; namespace App\Http\Resources;
use App\Models\Coupon;
use App\Services\CouponService;
use App\Services\PlanService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
@ -28,6 +31,13 @@ class CouponResource extends JsonResource
->map(fn(mixed $id): string => (string) $id) ->map(fn(mixed $id): string => (string) $id)
->values() ->values()
->all() ->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()
) )
]; ];
} }