123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- namespace Themes\Pro\modunawa\app\Http\Controllers\Shop;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- class AddressAddController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->callApiService = $callApiService;
- }
- public function index()
- {
- return view('views.shop.checkout.address.index')->with('codeTitle', [
- "sort('company-destina-bd')",
- ]);
- }
- public function store()
- {
- $response = $this->callApiService->callApi([
- 'url' => 'company-destina-bd-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => 0,
- 'ZipCode' => request('zip_code'),
- 'Addr1' => request('addr1'),
- 'Addr2' => request('addr2'),
- 'SeqNo' => (int)request('seq_no'),
- 'Sort' => request('sort'),
- ]
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- notify()->success(_e('Action completed'), 'Success', 'bottomRight');
- return redirect()->back();
- }
- public function show($id)
- {
- $response = $this->callApiService->callApi([
- 'url' => 'company-destina-bd-pick',
- 'data' => [
- 'Page' => [
- [
- 'Id' => (int)$id,
- ]
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- echo "<script>window.top.location.href = '" . url()->previous() . "'</script>";
- return false;
- }
- $address = reset($response['Page']);
- return view('views.shop.checkout.address.show', compact('address'))->with('codeTitle', [
- "sort('company-destina-bd')",
- ]);
- }
- public function update($id)
- {
- $response = $this->callApiService->callApi([
- 'url' => 'company-destina-bd-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => (int)$id,
- 'ZipCode' => request('zip_code'),
- 'Addr1' => request('addr1'),
- 'Addr2' => request('addr2'),
- 'Sort' => request('sort'),
- ]
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- notify()->success(_e('Action completed'), 'Success', 'bottomRight');
- return redirect()->back();
- }
- public function destroy($id){
- $response = $this->callApiService->callApi([
- 'url' => 'company-destina-bd-act',
- 'data' => [
- 'Page' => [
- [
- 'Id' => (int)-$id,
- ]
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($response)) {
- return response($response, 200);
- }
- return response($response, 200);
- }
- }
|