Bill.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\model\massager;
  3. use think\Model;
  4. class Bill extends Model
  5. {
  6. // 表名
  7. protected $name = 'massager_bill';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'currency_type_text'
  17. ];
  18. public function getCurrencyTypeList()
  19. {
  20. return ['money' => __('Money'), 'score' => __('Score')];
  21. }
  22. public function getCurrencyTypeTextAttr($value, $data)
  23. {
  24. $value = $value ? $value : (isset($data['currency_type']) ? $data['currency_type'] : '');
  25. $list = $this->getCurrencyTypeList();
  26. return isset($list[$value]) ? $list[$value] : '';
  27. }
  28. public function massager()
  29. {
  30. return $this->belongsTo('app\admin\model\Massager', 'massager_id', 'id', [], 'LEFT')->setEagerlyType(0);
  31. }
  32. }