Пример #1
0
 public function PaymentInfo()
 {
     if (Auth::check()) {
         if (Auth::user()->default_info_id == NULL) {
             $address = "";
         } else {
             $address = CustomerInfo::getAddressInfo(Auth::user()->default_info_id);
         }
     }
     return view("pages.payment_info", compact("address"));
 }
 public function BillDetail($bill_id)
 {
     if (Auth::check()) {
         $billInfo = Bill::find($bill_id);
         if ($billInfo->customer_id == Auth::user()->id) {
             $customerInfo = CustomerInfo::getAddressInfo($billInfo->customer_info_id);
             $billDetail = billDetail::getProducts($bill_id);
             return view("pages.finish_purchase", compact("billInfo", "customerInfo", "billDetail"));
         } else {
             return redirect()->route("home");
         }
     } else {
         return redirect()->route("login");
     }
 }
 public function DelAddress($customerInfoID)
 {
     if (Request::ajax()) {
         if (Auth::check()) {
             $info = CustomerInfo::find($customerInfoID);
             $info->delete();
             /*TH xoá info id mac dinh*/
             $default_info_id = customer::where("default_info_id", $customerInfoID)->count();
             if ($default_info_id == 1) {
                 //bi xoa
                 $id = CustomerInfo::select(["id"])->where("customer_id", Auth::user()->id)->first();
                 $customer = customer::find(Auth::user()->id);
                 if (count($id) == 1) {
                     //con dia chi khac duong cung cap
                     $customer->default_info_id = $id->id;
                 } else {
                     $customer->default_info_id = NULL;
                 }
                 $customer->save();
             }
             return json_encode(["result" => "Xoá thành công", "type" => "success"]);
         }
         return redirect()->route("thongtin.template");
     } else {
         return redirect()->route("login");
     }
 }
Пример #4
0
 public static function getAddressInfo($customerInfoId)
 {
     $address = CustomerInfo::join("province", "province.provinceid", "=", "customer_info.province_id")->join("district", "district.districtid", "=", "customer_info.district_id")->join("ward", "ward.wardid", "=", "customer_info.ward_id")->select(["customer_info.*", "province.name as province_name", "district.name as district_name", "ward.name as ward_name"])->where("id", $customerInfoId)->first();
     return $address;
 }