123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace app\admin\model\trade;
- use think\Model;
- use traits\model\SoftDelete;
- class Prizerecord extends Model
- {
- use SoftDelete;
- // 表名
- protected $name = 'prize_record';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- protected $deleteTime = 'delete_time';
- // 追加属性
- protected $append = [
- 'status_text',
- 'exchange_time_text',
- 'create_time_text',
- 'update_time_text',
- 'delete_time_text'
- ];
- public function getStatusList()
- {
- return ['bag' => __('Status bag'), 'exchange' => __('Status exchange'), 'delivery' => __('Status delivery'), 'received' => __('Status received')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getExchangeTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['exchange_time']) ? $data['exchange_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getCreateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getUpdateTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getDeleteTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['delete_time']) ? $data['delete_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getGoodsImageAttr($value)
- {
- return cdnurl($value, true);
- }
- protected function setExchangeTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setCreateTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setUpdateTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setDeleteTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- }
|