Changeset 2678354
- Timestamp:
- 02/14/2022 10:05:58 AM (4 years ago)
- Location:
- nobita-connect/trunk/admin
- Files:
-
- 1 deleted
- 1 edited
-
gravityforms (deleted)
-
lead-model.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nobita-connect/trunk/admin/lead-model.php
r2659142 r2678354 3 3 class NobitaLead 4 4 { 5 private $data = array();5 private $data = array(); 6 6 7 function __construct($default) { 7 public function __construct($default) 8 { 8 9 $this->data = $default; 9 }10 } 10 11 11 public function __set($name, $value)12 {13 $this->data[$name] = $value;14 }12 public function __set($name, $value) 13 { 14 $this->data[$name] = $value; 15 } 15 16 16 public function __get($name)17 {18 if (array_key_exists($name, $this->data)) {19 return $this->data[$name];20 }17 public function __get($name) 18 { 19 if (array_key_exists($name, $this->data)) { 20 return $this->data[$name]; 21 } 21 22 22 return null;23 }23 return null; 24 } 24 25 25 public function to_json(){ 26 $modelKeys = array("fullName","phone","address","email","birthdate","firstName" 27 ,"lastName","name","Email","Name","Birthdate","FullName","Phone","Address"); 26 public function to_json() 27 { 28 $modelKeys = array("fullName", "phone", "address", "email", "birthdate", "firstName" 29 , "lastName", "name", "Email", "Name", "Birthdate", "FullName", "Phone", "Address"); 28 30 29 $model = array_filter($this->data,function($value,$key) use ($modelKeys){ 30 return isset($value) && $value != "" && in_array($key,$modelKeys); 31 },ARRAY_FILTER_USE_BOTH ); 31 if (!isset($this->data["fullName"]) && isset($this->data["your-name"])) { 32 $this->data["fullName"] = $this->data["your-name"]; 33 unset($this->data["your-name"]); 34 } 32 35 33 $extra = array_filter($this->data,function($value,$key) use ($modelKeys){ 34 return isset($value) && $value != "" && !in_array($key,$modelKeys); 35 },ARRAY_FILTER_USE_BOTH ); 36 if (!isset($this->data["email"]) && isset($this->data["your-email"])) { 37 $this->data["email"] = $this->data["your-email"]; 38 unset($this->data["your-email"]); 39 } 40 41 $model = array_filter($this->data, function ($value, $key) use ($modelKeys) { 42 return isset($value) && $value != "" && in_array($key, $modelKeys); 43 }, ARRAY_FILTER_USE_BOTH); 44 45 $extra = array_filter($this->data, function ($value, $key) use ($modelKeys) { 46 return isset($value) && $value != "" && !in_array($key, $modelKeys); 47 }, ARRAY_FILTER_USE_BOTH); 36 48 37 49 $data = array( 38 "model" => $model,50 "model" => $model, 39 51 ); 40 if (count($extra)>0){41 $data["queryString"] = $extra;52 if (count($extra) > 0) { 53 $data["queryString"] = $extra; 42 54 } 43 return json_encode($data);44 }55 return json_encode($data); 56 } 45 57 } 46 47
Note: See TracChangeset
for help on using the changeset viewer.