public function postAddress(Request $request) { if (Auth::check()) { $customer = customer::find(Auth::user()->id); $customer->default_info_id = $request->get('customerInfoId'); $customer->save(); $customerInfo = CustomerInfo::getAddressInfo($request->get('customerInfoId')); $name = $customerInfo->first_name . " " . $customerInfo->last_name; $address = $customerInfo->address . " P." . $customerInfo->ward_name . ", Q." . $customerInfo->district_name . ",TP." . $customerInfo->province_name; $phone = $customerInfo->phone; return json_encode(["name" => $name, "address" => $address, "phone" => $phone]); } }
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"); } }
public function customersales_view(Request $request) { $sales = CustomerSales::find($request->input('id')); $payments = CustomerPayment::where('customer_sales_id', $request->input('id'))->get(); $docs = CustomerDocs::where('customer_sales_id', $request->input('id'))->get(); $customer = customer::find($sales->customer_id); return view('Sales.salesview')->with('sales', $sales)->with('payments', $payments)->with('docs', $docs)->with('customer', $customer); }