MemberWithdrawalController.php 1.6 KB

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