News.php 952 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\admin\model\wwh;
  3. use think\Model;
  4. class News extends Model
  5. {
  6. // 表名
  7. protected $name = 'wwh_news';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = false;
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'tjdata_text'
  17. ];
  18. public function newscategory()
  19. {
  20. return $this->hasone('\app\admin\model\wwh\Newscategory', 'id', 'newscategoryid')->setEagerlyType(0);
  21. }
  22. public function getTjdataList()
  23. {
  24. return ['0' => __('Tjdata 0'), '1' => __('Tjdata 1')];
  25. }
  26. public function getTjdataTextAttr($value, $data)
  27. {
  28. $value = $value ? $value : (isset($data['tjdata']) ? $data['tjdata'] : '');
  29. $list = $this->getTjdataList();
  30. return isset($list[$value]) ? $list[$value] : '';
  31. }
  32. }