ManageShareimg.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class ManageShareimg extends Model
  5. {
  6. // 表名
  7. protected $table = 'manage_shareimg';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'type_text',
  16. 'status_text',
  17. 'sex_text'
  18. ];
  19. public function getStatusList()
  20. {
  21. return ['normal' =>'正常','hidden' => '隐藏'];
  22. }
  23. public function getSexList()
  24. {
  25. return ['1' => '男频', '2' => '女频', '3'=> '活动'];
  26. }
  27. public function getTypeList()
  28. {
  29. return ['1' => '大图', '2' => '小图'];
  30. }
  31. public function getTypeTextAttr($value, $data)
  32. {
  33. $value = $value ? $value : $data['type'];
  34. $list = $this->getTypeList();
  35. return isset($list[$value]) ? $list[$value] : '';
  36. }
  37. public function getStatusTextAttr($value, $data)
  38. {
  39. $value = $value ? $value : $data['status'];
  40. $list = $this->getStatusList();
  41. return isset($list[$value]) ? $list[$value] : '';
  42. }
  43. public function getSexTextAttr($value, $data)
  44. {
  45. $value = $value ? $value : $data['sex'];
  46. $list = $this->getSexList();
  47. return isset($list[$value]) ? $list[$value] : '';
  48. }
  49. }