mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Model类的data方法支持设置某个属性的值
This commit is contained in:
@@ -160,19 +160,21 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量设置数据对象值
|
* 设置数据对象值(不进行修改器处理)
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $data 数据
|
* @param mixed $data 数据或者属性名
|
||||||
|
* @param mixed $value 值
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function data($data = '')
|
public function data($data, $value = null)
|
||||||
{
|
{
|
||||||
if (is_object($data)) {
|
if (is_object($data)) {
|
||||||
$data = get_object_vars($data);
|
$this->data = get_object_vars($data);
|
||||||
} elseif (!is_array($data)) {
|
} elseif (is_array($data)) {
|
||||||
throw new Exception('data type invalid', 10300);
|
$this->data = $data;
|
||||||
|
} else {
|
||||||
|
$this->data[$data] = $value;
|
||||||
}
|
}
|
||||||
$this->data = $data;
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user