Diy.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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\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 date('Y-m-d H:i:s', $value);
  46. }
  47. /**
  48. * 类型搜索器
  49. * @param Model $query
  50. * @param $value
  51. */
  52. public function searchNotTemplateNameAttr($query, $value)
  53. {
  54. if ($value && is_array($value)) {
  55. $query->whereNotIn('template_name', $value);
  56. }
  57. }
  58. /**
  59. * 类型搜索器
  60. * @param Model $query
  61. * @param $value
  62. */
  63. public function searchTypeAttr($query, $value)
  64. {
  65. if ($value != '') {
  66. if (is_array($value)) {
  67. $query->whereIn('type', $value);
  68. } else {
  69. $query->where('type', $value);
  70. }
  71. }
  72. }
  73. /**
  74. * 版本号搜索器
  75. * @param Model $query
  76. * @param $value
  77. */
  78. public function searchVersionAttr($query, $value)
  79. {
  80. if ($value != '') $query->where('version', $value);
  81. }
  82. /**
  83. * 是否使用搜索器
  84. * @param Model $query
  85. * @param $value
  86. */
  87. public function searchStatusAttr($query, $value)
  88. {
  89. if ($value != '') $query->where('status', $value);
  90. }
  91. /**
  92. * 名称搜索器
  93. * @param Model $query
  94. * @param $value
  95. */
  96. public function searchNameAttr($query, $value)
  97. {
  98. if ($value != '') $query->where('name', $value);
  99. }
  100. /**
  101. * 是否删除搜索器
  102. * @param Model $query
  103. * @param $value
  104. */
  105. public function searchIsDelAttr($query, $value)
  106. {
  107. if ($value !== '') $query->where('is_del', $value);
  108. }
  109. }