Esempio n. 1
0
 /**
  * function to get summary of balin checkout
  * 
  * 1. Get Session Cart & transaction
  * 2. Generate breadcrumb
  * 3. Generate view
  * @return view
  */
 public function get()
 {
     //1.Get Session Cart & transaction
     $carts = Session::get('carts');
     $APIUser = new APIUser();
     $order = $APIUser->getMeOrderInCart(['user_id' => Session::get('whoami')['id']]);
     if ($order['status'] != 'success') {
         Session::forget('carts');
         \App::abort(404);
     }
     //1a. get my point
     $my_point = $APIUser->getMeDetail(['user_id' => Session::get('whoami')['id']]);
     //1b. get my address
     $my_address = $APIUser->getMeAddress(['user_id' => Session::get('whoami')['id']]);
     //1c. get list product extension
     $APIProductExtension = new APIProductExtension();
     $product_extension = $APIProductExtension->getIndex();
     if ($product_extension['status'] != 'success') {
         $product_extension = null;
     }
     //1d. get list product extension
     $APICourier = new APICourier();
     $courier = $APICourier->getIndex();
     if ($courier['status'] != 'success') {
         $courier = null;
     }
     //2. Generate breadcrumb
     $breadcrumb = ['Checkout' => route('my.balin.checkout.get')];
     $this->page_attributes->breadcrumb = array_merge($this->page_attributes->breadcrumb, $breadcrumb);
     //3. Generate view
     $this->page_attributes->data = ['carts' => $carts, 'order' => $order, 'my_point' => $my_point['data']['total_point'], 'my_address' => $my_address['data']['data'], 'product_extension' => $product_extension, 'courier' => $courier['data']['data']];
     $this->page_attributes->subtitle = 'Checkout';
     $this->page_attributes->source = $this->page_attributes->source . 'index';
     return $this->generateView();
 }
 public function importShippingCost($id)
 {
     //get CSV
     $file_csv = Input::file('file');
     $attributes = [];
     $sheet = Excel::load($file_csv)->toArray();
     //data cost
     $cost = [];
     foreach ($sheet as $key => $value) {
         $cost[$key]['id'] = "";
         $cost[$key]['start_postal_code'] = $value[0];
         $cost[$key]['end_postal_code'] = $value[1];
         $cost[$key]['started_at'] = Carbon::createFromFormat('m/d/Y', $value[2])->format('Y-m-d H:i:s');
         $cost[$key]['cost'] = $value[3];
     }
     //get data courier
     $APICourier = new APICourier();
     $courier = $APICourier->getShow($id)['data'];
     $courier['shippingcosts'] = $cost;
     //save data
     $result = $APICourier->postData($courier);
     //response
     if ($result['status'] != 'success') {
         $this->errors = $result['message'];
     }
     //return view
     $this->page_attributes->success = "Data Ongkos Kirim Telah Ditambahkan";
     return $this->generateRedirectRoute('shop.courier.show', ['id' => $id]);
 }