Exemplo n.º 1
0
 public function updateAccount(Request $request)
 {
     $messge = array("status" => 0);
     $error = true;
     if (isset($_REQUEST['firstName']) && !empty($_REQUEST['firstName'])) {
         $firstName = $_REQUEST['firstName'];
         $messge['status'] = 1;
         $error = false;
     } else {
         $messge['status'] = -1;
         $error = true;
         $firstName = false;
     }
     if (isset($_REQUEST['lastName']) && !empty($_REQUEST['lastName'])) {
         $lastName = $_REQUEST['lastName'];
         $error = false;
         $messge['status'] = 1;
     } else {
         $messge['status'] = -1;
         $error = true;
         $lastName = false;
     }
     if (isset($_REQUEST['DOB']) && !empty($_REQUEST['DOB'])) {
         $DOB = $_REQUEST['DOB'];
         $error = false;
         $messge['status'] = 1;
     } else {
         $messge['status'] = -1;
         $error = true;
         $DOB = false;
     }
     if (isset($_REQUEST['phone']) && !empty($_REQUEST['phone'])) {
         $error = false;
         $Phone = $_REQUEST['phone'];
         $messge['status'] = 1;
     } else {
         $messge['status'] = -1;
         $error = true;
         $Phone = false;
     }
     if (isset($_REQUEST['Email']) && !empty($_REQUEST['Email'])) {
         $Email = $_REQUEST['Email'];
         $error = false;
         $messge['status'] = 1;
     } else {
         $messge['status'] = -1;
         $error = true;
         $Email = false;
     }
     if (isset($_REQUEST['address']) && !empty($_REQUEST['address'])) {
         $Address = $_REQUEST['address'];
         $messge['status'] = 1;
         $error = false;
     } else {
         $messge['status'] = -1;
         $error = true;
         $Address = false;
     }
     if (isset($_REQUEST['postalCode']) && !empty($_REQUEST['postalCode'])) {
         $PostalCode = $_REQUEST['postalCode'];
         $error = false;
         $messge['status'] = 1;
     } else {
         $messge['status'] = -1;
         $error = true;
         $PostalCode = false;
     }
     $Gender = $_REQUEST['rdbGender'];
     $Country = $_REQUEST['country'];
     $user = $request->session()->get('user');
     if (is_null($user)) {
         return false;
     }
     if ($error == false) {
         if ($user[0]->type == "tenant") {
             //Save room for user
             $tenant = User::find($user[0]->id);
             $tenant->FirstName = $firstName;
             $tenant->LastName = $lastName;
             $tenant->DOB = $DOB;
             $tenant->Address = $Address;
             $tenant->Country = $Country;
             $tenant->PostalCode = $PostalCode;
             $tenant->save();
             $messge['status'] = 1;
             $messge['msg'] = $user[0]->UserName . ",Tenant Successfully updated";
         } elseif ($user[0]->type == "Landlord") {
             $landlord = userLandlord::find($user[0]->id);
             $landlord->FirstName = $firstName;
             $landlord->LastName = $lastName;
             $landlord->DOB = $DOB;
             $landlord->phone = $Phone;
             $landlord->Address = $Address;
             $landlord->Country = $Country;
             $landlord->PostalCode = $PostalCode;
             $landlord->save();
             $messge['status'] = 1;
             $messge['msg'] = $user[0]->UserName . " Landlord Successfully updated";
         } else {
             $vehicleowner = vehicleOwnerModel::find($user[0]->id);
             $vehicleowner->FirstName = $firstName;
             $vehicleowner->LastName = $lastName;
             $vehicleowner->DOB = $DOB;
             $vehicleowner->phone = $Phone;
             $vehicleowner->Address = $Address;
             $vehicleowner->Country = $Country;
             $vehicleowner->PostalCode = $PostalCode;
             $vehicleowner->save();
             $messge['status'] = 1;
             $messge['msg'] = $user[0]->UserName . ", Vehicle owner Successfully updated";
         }
     } else {
         $messge['status'] = -1;
         $messge['msg'] = " Update Failed";
     }
     echo json_encode($messge);
 }
Exemplo n.º 2
0
 public function updateAccount(Request $request)
 {
     $messge = array("status" => 0);
     if (isset($_REQUEST['firstName']) && !empty($_REQUEST['firstName'])) {
         $firstName = $_REQUEST['firstName'];
     }
     if (isset($_REQUEST['lastName']) && !empty($_REQUEST['lastName'])) {
         $lastName = $_REQUEST['lastName'];
     }
     if (isset($_REQUEST['userName']) && !empty($_REQUEST['userName'])) {
         $userName = $_REQUEST['userName'];
     }
     if (isset($_REQUEST['Password']) && !empty($_REQUEST['Password'])) {
         $Password = md5($_REQUEST['Password']);
     }
     if (isset($_REQUEST['DOB']) && !empty($_REQUEST['DOB'])) {
         $DOB = $_REQUEST['DOB'];
     }
     if (isset($_REQUEST['phone']) && !empty($_REQUEST['phone'])) {
         $Phone = $_REQUEST['phone'];
     }
     if (isset($_REQUEST['Email']) && !empty($_REQUEST['Email'])) {
         $Email = $_REQUEST['Email'];
     }
     if (isset($_REQUEST['address']) && !empty($_REQUEST['address'])) {
         $Address = $_REQUEST['address'];
     }
     if (isset($_REQUEST['postalCode']) && !empty($_REQUEST['postalCode'])) {
         $PostalCode = $_REQUEST['postalCode'];
     }
     $Gender = $_REQUEST['rdbGender'];
     $Country = $_REQUEST['country'];
     //$memberType = $_REQUEST['userType'];
     $user = $request->session()->get('user');
     if ($user[0]->type == "tenant") {
         //Save room for user
         $tenant = User::find($user[0]->ID);
         $tenant->FirstName = $firstName;
         $tenant->LastName = $lastName;
         $tenant->Password = md5($Password);
         $tenant->save();
     } elseif ($user[0]->type == "landlord") {
         $landlord = userLandlord::find($user[0]->ID);
         $landlord->FirstName = $firstName;
         $landlord->LastName = $lastName;
         $landlord->Password = md5($Password);
         $landlord->save();
     } else {
         $vehicleowner = vehicleOwnerModel::find($user[0]->ID);
         $vehicleowner->FirstName = $firstName;
         $vehicleowner->LastName = $lastName;
         $vehicleowner->Password = md5($Password);
         $vehicleowner->save();
     }
     echo json_encode($messge);
 }