fix(coupon): correct knows issues

This commit is contained in:
xboard
2025-01-23 16:14:18 +08:00
parent 8f88e11403
commit caade5c791
6 changed files with 41 additions and 10 deletions
@@ -11,11 +11,11 @@ class CouponController extends Controller
{
public function check(Request $request)
{
$request->validate([
'code' => 'required|string',
'plan_id' => 'required|integer',
'period' => 'nullable|string',
]);
// $request->validate([
// 'code' => 'required|string',
// 'plan_id' => 'required|integer',
// 'period' => 'nullable|string',
// ]);
if (empty($request->input('code'))) {
return $this->fail([422,__('Coupon cannot be empty')]);
}
+2 -1
View File
@@ -114,7 +114,8 @@ class PlanService
*/
public static function convertToLegacyPeriod(string $period): string
{
return Plan::LEGACY_PERIOD_MAPPING[$period] ?? $period;
$flippedMapping = array_flip(Plan::LEGACY_PERIOD_MAPPING);
return $flippedMapping[$period] ?? $period;
}
/**