public function getIndex() { //getIndex() like a __constructor try { // $customer = customer::find(5); // $customer->username = "******"; // $customer->email = "*****@*****.**"; // $customer->name = "Jackie"; // $customer->tel = "0831111111"; // $customer->type = "Admin"; // $customer->password = '******'; //$customer->save() // customer::where("name","wesarut")->update(["wesarut" => "jack"]) // customer::find(2)->delete() // if($customer = customer::all()){ // return view('customer',['cus' => $customer]); // }else{ throw new Exception('Execute Failure!'); } if ($customer = customer::where('name', 'nuchnard')->get()) { return view('customer', $customer); } else { throw new Exception('Execute Failure!'); } } catch (Exception $e) { return $e->Message; } }
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 Signup(SignupRequest $request) { /*them thanh vien*/ $firstname = $request->get("firstname"); $lastname = $request->get("lastname"); $pass = Hash::make($request->get("password")); $email = $request->get("email"); $gender = $request->get("gender"); $birthday = $request->get("birthday"); $default_list_id = 0; $customer = customer::create(["email" => $email, "password" => $pass, "first_name" => $firstname, "last_name" => $lastname, "default_list_id" => $default_list_id, "gender" => $gender, "birthday" => $birthday]); /*tao danh sach mac dinh*/ LoveList::create(["customer_id" => $customer->id, "name" => "danh sách mặc định"]); $default_list_id = LoveList::select(["id"])->where("customer_id", $customer->id)->first(); /*cap nhat id danh sach mac dinh cho customer*/ customer::where("id", $customer->id)->update(["default_list_id" => $default_list_id->id]); return redirect()->route("login")->with("result", "Đăng kí thành công"); }
public function SetDefaultList($list_id) { if (Request::ajax()) { if (Auth::check()) { $customer_id = Auth::user()->id; customer::where("id", $customer_id)->update(["default_list_id" => $list_id]); } } }
public function searchPage(FormRequest $request, $name = "") { if ($name != "") { $tensanpham = $name; } else { $tensanpham = $request->get("ten_san_pham"); } $products = Products::getProductByName($tensanpham, 25); $products->setPath("tim-kiem"); $arrayCurrentCateName = [["name" => "Kết quả tìm kiếm {$tensanpham}"]]; $lovedProductsId = ["0"]; if (Auth::check()) { $lovedProductsId = customer::LovedProduct("id"); } return view("pages.list_products", compact("products", "arrayParentName", "arrayCurrentCateName", "lovedProductsId")); }
public function register_user() { $input = Request::all(); customer::create($input); return redirect('about'); }
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 addtravel(Requests\travelvalidate $request) { try { $input = $request->all(); $customer = new customer(); $customer->address = Input::get('address'); $customer->email = Input::get('email'); $customer->contact_no = Input::get('telephone_number'); $customer->name = Input::get('name'); $customer->lane1 = Input::get('lane1'); $customer->lane2 = Input::get('lane2'); $customer->city = Input::get('city'); $customer->save(); $travel = new travel(); $travel->cus_id = $customer->cus_id; $travel->save(); $changelog = new changes_log(); $changelog->user = '******'; $changelog->action_type = 'Add Travel Agent'; $changelog->description = 'Customer ' . $customer->name . ' added as a travel agent'; $changelog->save(); return redirect('/guest_profile/travel_agent_list')->with('succ_status', 'Successfully Added'); } catch (Exception $e) { return redirect('/guest_profile/travel_agent_list/create')->with(['exception' => 'You cannot add the Travel Agent. Please Chack you E-maile and Contact No !']); } }
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); }