12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\admin\model;
- use think\Model;
- use traits\model\SoftDelete;
- use app\common\library\Tenim;
- class Company extends Model
- {
- use SoftDelete;
-
- // 表名
- protected $table = 'company';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = 'deletetime';
- // 追加属性
- protected $append = [
- 'status_text'
- ];
- protected static function init()
- {
- self::afterUpdate(function ($row) {
- $changed = $row->getChangedData();
- //如果有修改头像或昵称,同步到im
- if (isset($changed['companyname']) || isset($changed['avatar'])) {
- //user_用户端小程序,master_师傅,kefu_客服
- $tenim = new Tenim();
- $rs = $tenim->useredit('kefu_'. $row['id'], $row['companyname'], localpath_to_netpath($row['avatar']));
- }
- });
- }
-
-
- public function getStatusList()
- {
- return ['1' => __('Status 1'), '0' => __('Status 0')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|