コード例 #1
0
 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;
     }
 }
コード例 #2
0
 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");
 }
コード例 #3
0
 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]);
         }
     }
 }
コード例 #4
0
 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");
     }
 }