Xboard/app/Http/Controllers/V1/User/CouponController.php

24 lines
688 B
PHP
Raw Normal View History

2023-11-17 01:44:01 -05:00
<?php
namespace App\Http\Controllers\V1\User;
2023-12-04 07:40:49 -05:00
use App\Exceptions\ApiException;
2023-11-17 01:44:01 -05:00
use App\Http\Controllers\Controller;
use App\Services\CouponService;
use Illuminate\Http\Request;
class CouponController extends Controller
{
public function check(Request $request)
{
if (empty($request->input('code'))) {
return $this->fail([422,__('Coupon cannot be empty')]);
2023-11-17 01:44:01 -05:00
}
$couponService = new CouponService($request->input('code'));
$couponService->setPlanId($request->input('plan_id'));
$couponService->setUserId($request->user['id']);
$couponService->check();
return $this->success($couponService->getCoupon());
2023-11-17 01:44:01 -05:00
}
}