register('master_'. $worker_id, $row['truename'], localpath_to_netpath($row['avatar'])); }); self::afterUpdate(function ($row) { $changed = $row->getChangedData(); //如果有修改头像或昵称,同步到im if (isset($changed['truename']) || isset($changed['avatar'])) { //user_用户端小程序,master_师傅,kefu_客服 $tenim = new Tenim(); $rs = $tenim->useredit('master_'. $row['id'], $row['truename'], localpath_to_netpath($row['avatar'])); } }); } public function getStatusList() { return ['1' => __('Status 1'), '0' => __('Status 0'), '-1' => __('Status -1')]; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getPrevtimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getLogintimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setPrevtimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setLogintimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } public function company() { return $this->belongsTo('Company', 'company_id', 'id', [], 'LEFT')->setEagerlyType(0); } }