2019-12-31 17:49:24 +08:00
|
|
|
<?php
|
|
|
|
|
2020-01-29 16:08:50 +08:00
|
|
|
namespace App\Http\Controllers\User;
|
2019-12-31 17:49:24 +08:00
|
|
|
|
2020-01-29 16:08:50 +08:00
|
|
|
use App\Http\Controllers\Controller;
|
2021-08-28 15:32:55 +08:00
|
|
|
use App\Services\CouponService;
|
2019-12-31 17:49:24 +08:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Models\Coupon;
|
|
|
|
|
|
|
|
class CouponController extends Controller
|
|
|
|
{
|
2020-01-11 13:36:52 +08:00
|
|
|
public function check(Request $request)
|
|
|
|
{
|
2020-01-01 15:59:53 +08:00
|
|
|
if (empty($request->input('code'))) {
|
2021-06-12 00:56:39 +08:00
|
|
|
abort(500, __('Coupon cannot be empty'));
|
2020-01-01 15:59:53 +08:00
|
|
|
}
|
2021-08-28 15:32:55 +08:00
|
|
|
$couponService = new CouponService($request->input('code'));
|
|
|
|
$couponService->setPlanId($request->input('plan_id'));
|
|
|
|
$couponService->setUserId($request->session()->get('id'));
|
|
|
|
$couponService->check();
|
2020-01-01 15:59:53 +08:00
|
|
|
return response([
|
2021-08-28 15:32:55 +08:00
|
|
|
'data' => $couponService->getCoupon()
|
2020-01-01 15:59:53 +08:00
|
|
|
]);
|
2019-12-31 17:49:24 +08:00
|
|
|
}
|
2020-01-11 13:36:52 +08:00
|
|
|
}
|