12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Themes\kbgolf\pro\app\Http\Controllers\Auth;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- use Carbon\Carbon;
- class MemberWithdrawalController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->callApiService = $callApiService;
- }
- public function index()
- {
- return view('views.auth.member-withdrawal');
- }
- public function store()
- {
- $response = $this->callApiService->callApi([
- 'url' => 'member-login',
- 'data' => [
- 'Email' => session('member')['Email'],
- 'Password' => request('password')
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error('현재 비밀번호를 입력해주세요', 'Error', 'bottomRight');
- return redirect()->back();
- }
- $setup = $this->callApiService->callApi([
- 'url' => 'setup-get',
- 'data' => [
- 'SetupCode' => 'withdraw-default',
- ]
- ]);
- $withdrawDt = Carbon::now()->addWeeks($setup['ActiveWeeks']);
- $memberId = session('member')['MemberId'];
- $memberSecuredAct = $this->callApiService->callApi([
- 'url' => 'member-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => $memberId,
- 'WithdrawOn' => $withdrawDt->timestamp,
- ]
- ]
- ],
- ]);
- if ($this->callApiService->verifyApiError($memberSecuredAct)) {
- notify()->error($memberSecuredAct['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- // notify()->success(_e('Action completed'), 'Success', 'bottomRight');
- return redirect()->route('member-logout');
- }
- }
|