123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- namespace Themes\kbgolf\pro\app\Http\Controllers\MyPage;
- use App\Helpers\ResponseConverter;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- use Illuminate\Pagination\LengthAwarePaginator;
- class MemberEditController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->callApiService = $callApiService;
- }
- public function index()
- {
- $memberId = session('member')['MemberId'];
- $listType1Book = $this->callApiService->callApi([
- 'url' => 'list-type1-book',
- 'data' => [
- 'Book' => [
- [
- 'QueryVars' => [
- 'QueryName' => 'pro:shop/company-contact-bd',
- 'IsntPagination' => true,
- ],
- 'ListType1Vars' => [
- 'OrderBy' => 'sort asc'
- ],
- 'PageVars' => [
- 'Limit' => 100000
- ]
- ],
- [
- 'QueryVars' => [
- 'QueryName' => 'pro:shop/company-destina-bd',
- 'IsntPagination' => true,
- ],
- 'ListType1Vars' => [
- 'OrderBy' => 'sort asc'
- ],
- 'PageVars' => [
- 'Limit' => 100000
- ]
- ],
- [
- 'QueryVars' => [
- 'QueryName' => 'pro/member-company-single',
- 'SimpleFilter' => "mx.id = $memberId",
- 'IsntPagination' => true,
- ],
- 'PageVars' => [
- 'Limit' => 100000
- ]
- ],
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($listType1Book)) {
- notify()->error($listType1Book['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- $member = $listType1Book['Book'][2]['Page'][0];
- // dump($member);
- return view('views.my-page.member-edit', compact('listType1Book', 'member'))
- ->with('codeTitle', [
- "sort('company-contact-bd')", "sort('company-destina-bd')", "paymethod('sorder')",
- ]);
- }
- public function show()
- {
- $memberId = session('member')['MemberId'];
- $response = $this->callApiService->callApi([
- 'url' => 'list-type1-page',
- 'data' => [
- 'QueryVars' => [
- 'QueryName' => 'pro/member-company-single',
- 'SimpleFilter' => "mx.id = $memberId",
- 'IsntPagination' => true,
- ],
- 'PageVars' => [
- 'Limit' => 100000
- ]
- ],
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- echo "<script>window.top.location.href = '" . url()->previous() . "'</script>";
- return false;
- }
- $member = reset($response['Page']);
- // dump($member);
- return view('views.my-page.member-edit.show', compact('member'));
- }
- public function update($id)
- {
- $response = $this->callApiService->callApi([
- 'url' => 'member-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => (int)$id,
- 'FirstName' => request('first_name'),
- ]
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- if (request('van')) {
- $company_json = json_encode([
- 'Van' => request('van'),
- 'VanId' => request('van_id'),
- 'VanPw' => request('van_pw'),
- ]);
- }
- // dd($company_json);
- $response = $this->callApiService->callApi([
- 'url' => 'company-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => (int)session('member')['MemberId'],
- 'TaxNo' => request('tax_no'),
- 'CompanyJson' => $company_json ?? ''
- ]
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- // notify()->success(_e('Action completed'), 'Success', 'bottomRight');
- return redirect()->back();
- }
- }
|