UserBalance.php 886 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class UserBalance extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'userid' => 'int',
  10. 'title' => 'string',
  11. 'origin_value' => 'decimal',
  12. 'value' => 'decimal',
  13. 'remark' => 'string',
  14. 'status' => 'int',
  15. 'createtime' => 'int',
  16. 'yeartime' => 'int',
  17. 'monthtime' => 'int',
  18. ];
  19. // 设置字段自动转换类型
  20. protected $type = [
  21. 'createtime' => 'timestamp:Y-m-d H:i:s',
  22. ];
  23. // 关联User
  24. public function user()
  25. {
  26. return $this->hasOne(User::class, "id", "userid");
  27. }
  28. public function getStatusTextAttr($value,$data)
  29. {
  30. $status = [1=>'待处理', 2=>'已处理'];
  31. return $status[$data['status']];
  32. }
  33. }