123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Topicdongtai extends Model
- {
-
-
- // 表名
- protected $name = 'topic_dongtai';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'type_text',
- 'is_public_text',
- 'toptime_text',
- 'auditstatus_text',
- 'audittime_text'
- ];
- protected static function init()
- {
- self::afterUpdate(function ($row) {
- $changed = $row->getChangedData();
- //如果有修改密码
- if (isset($changed['auditstatus'])) {
- //如果强制审核,默认不通过
- $dongtai_audit_switch = config('site.dongtai_audit_switch');
- if($dongtai_audit_switch == 1){
- //暂时不影响
- }
- if ($changed['auditstatus'] == 2) {
- //驳回
- $msg_id = \app\common\model\Message::addMessage($row['user_id'],'动态审核','动态审核不通过:'.$row['auditremark']);
- } elseif($changed['auditstatus'] == 1) {
- //通过
- //$msg_id = \app\common\model\Message::addMessage($row['user_id'],'动态审核','动态审核通过');
- }
- }
- });
- }
-
- public function getTypeList()
- {
- return ['1' => __('Type 1'), '2' => __('Type 2')];
- }
- public function getIsPublicList()
- {
- return ['1' => __('Is_public 1'), '2' => __('Is_public 2')];
- }
- public function getAuditstatusList()
- {
- return ['0' => __('Auditstatus 0'), '1' => __('Auditstatus 1'), '2' => __('Auditstatus 2')];
- }
- public function getTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
- $list = $this->getTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsPublicTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_public']) ? $data['is_public'] : '');
- $list = $this->getIsPublicList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getToptimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['toptime']) ? $data['toptime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getAuditstatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['auditstatus']) ? $data['auditstatus'] : '');
- $list = $this->getAuditstatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getAudittimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['audittime']) ? $data['audittime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setToptimeAttr($value)
- {
- return $value === '' ? 0 : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setAudittimeAttr($value)
- {
- return $value === '' ? 0 : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|