1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\common\model;
- use think\Model;
- class ReferralMany extends Model
- {
- // 表名
- protected $table = 'referral_many';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'short_url_type_text',
- 'state_text'
- ];
- // 类型转换
- protected $type = [
- 'push_json' => 'json',
- ];
- public function getShortUrlTypeList()
- {
- return ['1' => '腾讯短连接', '2' => '微博短连接'];
- }
- public function getStateList()
- {
- return ['0' => '禁用', '1' => '正常'];
- }
- public function getShortUrlTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['short_url_type'];
- $list = $this->getShortUrlTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStateTextAttr($value, $data)
- {
- $value = $value ? $value : $data['state'];
- $list = $this->getStateList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- }
|