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'))) {
|
2023-12-06 15:01:32 -05:00
|
|
|
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();
|
2023-12-06 15:01:32 -05:00
|
|
|
return $this->success($couponService->getCoupon());
|
2023-11-17 01:44:01 -05:00
|
|
|
}
|
|
|
|
}
|