mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 07:12:47 +08:00
Model类增加只读字段支持
This commit is contained in:
@@ -60,6 +60,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
protected $pk;
|
protected $pk;
|
||||||
// 数据表字段信息 留空则自动获取
|
// 数据表字段信息 留空则自动获取
|
||||||
protected $field = [];
|
protected $field = [];
|
||||||
|
// 只读字段
|
||||||
|
protected $readonly = [];
|
||||||
// 显示属性
|
// 显示属性
|
||||||
protected $visible = [];
|
protected $visible = [];
|
||||||
// 隐藏属性
|
// 隐藏属性
|
||||||
@@ -663,6 +665,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($this->readonly)) {
|
||||||
|
// 只读字段不允许更新
|
||||||
|
foreach ($this->readonly as $key => $field) {
|
||||||
|
if (isset($data[$field])) {
|
||||||
|
unset($data[$field]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($where) && !empty($this->updateWhere)) {
|
if (empty($where) && !empty($this->updateWhere)) {
|
||||||
$where = $this->updateWhere;
|
$where = $this->updateWhere;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user