Diy.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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\diy;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. class Diy extends BaseModel
  16. {
  17. use ModelTrait;
  18. /**
  19. * 数据表主键
  20. * @var string
  21. */
  22. protected $pk = 'id';
  23. /**
  24. * 模型名称
  25. * @var string
  26. */
  27. protected $name = 'diy';
  28. protected $updateTime = false;
  29. /**
  30. * 添加时间获取器
  31. * @param $value
  32. * @return false|string
  33. */
  34. public function getAddTimeAttr($value)
  35. {
  36. return date('Y-m-d H:i:s', $value);
  37. }
  38. /**
  39. * 修改时间获取器
  40. * @param $value
  41. * @return false|string
  42. */
  43. public function getUpdateTimeAttr($value)
  44. {
  45. return $value ? date('Y-m-d H:i:s', $value) : '暂无';
  46. }
  47. /**
  48. * 类型搜索器
  49. * @param Model $query
  50. * @param $value
  51. */
  52. public function searchTypeAttr($query, $value)
  53. {
  54. if ($value !== '') {
  55. if ($value == -1) {
  56. $query->whereIn('type', [0, 2]);
  57. } else {
  58. $query->where('type', $value);
  59. }
  60. }
  61. }
  62. /**
  63. * 版本号搜索器
  64. * @param Model $query
  65. * @param $value
  66. */
  67. public function searchVersionAttr($query, $value)
  68. {
  69. if ($value != '') $query->where('version', $value);
  70. }
  71. /**
  72. * 是否使用搜索器
  73. * @param Model $query
  74. * @param $value
  75. */
  76. public function searchStatusAttr($query, $value)
  77. {
  78. if ($value != '') $query->where('status', $value);
  79. }
  80. /**
  81. * 名称搜索器
  82. * @param Model $query
  83. * @param $value
  84. */
  85. public function searchNameAttr($query, $value)
  86. {
  87. if ($value != '') $query->where('name', $value);
  88. }
  89. /**
  90. * @param $query
  91. * @param $value
  92. */
  93. public function searchIsDelAttr($query, $value)
  94. {
  95. if ($value !== '') $query->where('is_del', $value);
  96. }
  97. }