12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\admin\model;
- use think\Model;
- use app\common\constants\Common;
- class CustomMedia extends Model
- {
- // 表名
- protected $table = 'custom_media';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'is_share_vip_manager_text',
- 'is_share_vip_operator_text',
- 'message_type_text',
- 'status_text'
- ];
- public function getIsShareVipManagerList()
- {
- return ['0' => __('Is_share_vip_manager 0'), '1' => __('Is_share_vip_manager 1')];
- }
- public function getIsShareVipOperatorList()
- {
- return ['0' => __('Is_share_vip_operator 0'), '1' => __('Is_share_vip_operator 1')];
- }
- public function getMessageTypeList()
- {
- return ['0' => __('Message_type 0'), '1' => __('Message_type 1')];
- }
- public function getStatusList()
- {
- return ['normal' => __('Status normal'), 'hidden' => __('Status hidden')];
- }
- public function getIsShareVipManagerTextAttr($value, $data)
- {
- $value = $value ? $value : $data['is_share_vip_manager'];
- $list = $this->getIsShareVipManagerList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsShareVipOperatorTextAttr($value, $data)
- {
- $value = $value ? $value : $data['is_share_vip_operator'];
- $list = $this->getIsShareVipOperatorList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getMessageTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['message_type'];
- $list = $this->getMessageTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : $data['status'];
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- /**
- * 逻辑删除素材
- * @param $mediaId 素材ID
- * @return int|bool
- */
- public function deleteMedia($mediaId)
- {
- return $this->save(['status' => Common::STATUS_HIDDEN], ['id' => $mediaId]);
- }
- }
|