TemplateMessage.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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\other;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * 消息模板Model
  17. * Class TemplateMessage
  18. * @package app\model\other
  19. */
  20. class TemplateMessage extends BaseModel
  21. {
  22. use ModelTrait;
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'template_message';
  33. /**
  34. * 模板ID搜索器
  35. * @param Model $query
  36. * @param $value
  37. * @param $data
  38. */
  39. public function searchTempIdAttr($query, $value, $data)
  40. {
  41. $query->where('temp_id', $value);
  42. }
  43. /**
  44. * @param Model $query
  45. * @param $value
  46. */
  47. public function searchTypeAttr($query, $value)
  48. {
  49. if (in_array($value,[0,1])){
  50. $query->where('type', $value);
  51. }
  52. }
  53. /**
  54. * @param Model $query
  55. * @param $value
  56. */
  57. public function searchStatusAttr($query, $value)
  58. {
  59. if ($value) {
  60. $query->where('status', $value);
  61. }
  62. }
  63. /**
  64. * @param Model $query
  65. * @param $value
  66. */
  67. public function searchNameAttr($query, $value)
  68. {
  69. if ($value) {
  70. $query->where('name', 'LIKE',"%$value%");
  71. }
  72. }
  73. }