MemberWithdrawalController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Themes\kbgolf\pro\app\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\CallApiService;
  5. use Carbon\Carbon;
  6. class MemberWithdrawalController extends Controller
  7. {
  8. private $callApiService;
  9. public function __construct(CallApiService $callApiService)
  10. {
  11. $this->callApiService = $callApiService;
  12. }
  13. public function index()
  14. {
  15. return view('views.auth.member-withdrawal');
  16. }
  17. public function store()
  18. {
  19. $response = $this->callApiService->callApi([
  20. 'url' => 'member-login',
  21. 'data' => [
  22. 'Email' => session('member')['Email'],
  23. 'Password' => request('password')
  24. ]
  25. ]);
  26. if ($this->callApiService->verifyApiError($response)) {
  27. notify()->error('현재 비밀번호를 입력해주세요', 'Error', 'bottomRight');
  28. return redirect()->back();
  29. }
  30. $setup = $this->callApiService->callApi([
  31. 'url' => 'setup-get',
  32. 'data' => [
  33. 'SetupCode' => 'withdraw-default',
  34. ]
  35. ]);
  36. $withdrawDt = Carbon::now()->addWeeks($setup['ActiveWeeks']);
  37. $memberId = session('member')['MemberId'];
  38. $memberSecuredAct = $this->callApiService->callApi([
  39. 'url' => 'member-act',
  40. 'data' => [
  41. 'Page' => [
  42. [
  43. 'Id' => $memberId,
  44. 'WithdrawOn' => $withdrawDt->timestamp,
  45. ]
  46. ]
  47. ],
  48. ]);
  49. if ($this->callApiService->verifyApiError($memberSecuredAct)) {
  50. notify()->error($memberSecuredAct['body'], 'Error', 'bottomRight');
  51. return redirect()->back();
  52. }
  53. // notify()->success(_e('Action completed'), 'Success', 'bottomRight');
  54. return redirect()->route('member-logout');
  55. }
  56. }