Honor.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\model\wwh;
  3. use think\Model;
  4. class Honor extends Model
  5. {
  6. // 表名
  7. protected $name = 'wwh_honor';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'type_text',
  17. 'lang_text'
  18. ];
  19. public function getTypeList()
  20. {
  21. return ['1' => __('资质证书'), '2' => __('荣誉证书'), '3' => __('其他')];
  22. }
  23. public function getTypeTextAttr($value, $data)
  24. {
  25. $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
  26. $list = $this->getTypeList();
  27. return isset($list[$value]) ? $list[$value] : '';
  28. }
  29. public function getLangList()
  30. {
  31. return ['1' => __('Lang 1'), '2' => __('Lang 2')];
  32. }
  33. public function getLangTextAttr($value, $data)
  34. {
  35. $value = $value ?: ($data['lang'] ?? '');
  36. $list = $this->getLangList();
  37. return $list[$value] ?? '';
  38. }
  39. }