1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 审批申请-审批人修改记录模型
- */
- class ApproveInfoLog extends Model
- {
- // 表名
- protected $name = 'approve_info_log';
- // 追加属性
- protected $append = [
- 'before_text',
- 'after_text',
- ];
- public function getBeforeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['before']) ? $data['before'] : '');
- return $value ? json_decode($value,true) : [];
- }
- public function getAfterTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['after']) ? $data['after'] : '');
- return $value ? json_decode($value,true) : [];
- }
- // 关联用户 (后台)
- public function user()
- {
- return $this->belongsTo(User::class, 'user_id', 'userid');
- }
- protected static function init()
- {
- self::beforeInsert(function ($row) {
- $changed = $row->getChangedData();
- });
- self::beforeUpdate(function ($row) {
- $changed = $row->getChangedData();
- });
- self::afterInsert(function ($row) {
- $changed = $row->getChangedData();
- });
- self::afterUpdate(function ($row) {
- $changed = $row->getChangedData();
- });
- }
- }
|