mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
Model类增加只读字段支持
This commit is contained in:
@@ -60,6 +60,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
protected $pk;
|
||||
// 数据表字段信息 留空则自动获取
|
||||
protected $field = [];
|
||||
// 只读字段
|
||||
protected $readonly = [];
|
||||
// 显示属性
|
||||
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)) {
|
||||
$where = $this->updateWhere;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user