UserInvoice.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\user;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * Class UserInvoice
  17. * @package app\model\live
  18. */
  19. class UserInvoice extends BaseModel
  20. {
  21. use ModelTrait;
  22. protected $pk = 'id';
  23. protected $name = 'user_invoice';
  24. protected $autoWriteTimestamp = 'int';
  25. protected $createTime = 'add_time';
  26. protected function setAddTimeAttr()
  27. {
  28. return time();
  29. }
  30. /**
  31. * 添加时间获取器
  32. * @param $value
  33. * @return false|string
  34. */
  35. public function getAddTimeAttr($value)
  36. {
  37. if (!empty($value)) {
  38. return date('Y-m-d H:i:s', (int)$value);
  39. }
  40. return '';
  41. }
  42. /**
  43. * @param Model $query
  44. * @param $value
  45. */
  46. public function searchUidAttr($query, $value)
  47. {
  48. if ($value !== '') $query->where('uid', $value);
  49. }
  50. /**
  51. * @param Model $query
  52. * @param $value
  53. */
  54. public function searchHeaderTypeAttr($query, $value)
  55. {
  56. if ($value !== '') $query->where('header_type', $value);
  57. }
  58. /**
  59. * @param Model $query
  60. * @param $value
  61. */
  62. public function searchTypeAttr($query, $value)
  63. {
  64. if ($value !== '') $query->where('type', $value);
  65. }
  66. /**
  67. * @param Model $query
  68. * @param $value
  69. */
  70. public function searchIsDefaultAttr($query, $value)
  71. {
  72. if ($value !== '') $query->whereLike('is_default', $value);
  73. }
  74. /**
  75. * @param Model $query
  76. * @param $value
  77. */
  78. public function searchIsDelAttr($query, $value)
  79. {
  80. if ($value !== '') $query->where('is_del', $value);
  81. }
  82. }