mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Model类是__unset和__isset方法判断
This commit is contained in:
@@ -1975,7 +1975,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
public function __isset($name)
|
public function __isset($name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (array_key_exists($name, $this->data)) {
|
if (array_key_exists($name, $this->data) || array_key_exists($name, $this->relation)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->getAttr($name);
|
$this->getAttr($name);
|
||||||
@@ -1995,7 +1995,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public function __unset($name)
|
public function __unset($name)
|
||||||
{
|
{
|
||||||
unset($this->data[$name]);
|
unset($this->data[$name], $this->relation[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
|
|||||||
Reference in New Issue
Block a user