StoreServiceSpeechcraft.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. declare (strict_types=1);
  12. namespace app\model\service;
  13. use app\model\other\Category;
  14. use crmeb\basic\BaseModel;
  15. use crmeb\traits\ModelTrait;
  16. use think\Model;
  17. /**
  18. * 客服话术
  19. * @mixin Model
  20. */
  21. class StoreServiceSpeechcraft extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 表名
  26. * @var string
  27. */
  28. protected $name = 'store_service_speechcraft';
  29. /**
  30. * 主键
  31. * @var string
  32. */
  33. protected $pk = 'id';
  34. /**
  35. * 时间格式化
  36. * @param $value
  37. * @param $data
  38. * @return false|string
  39. */
  40. public function getAddTimeAttr($value, $data)
  41. {
  42. return date('Y-m-d H:i:s', $value);
  43. }
  44. /**
  45. * 关联标签分类
  46. * @return \think\model\relation\HasOne
  47. */
  48. public function cateName()
  49. {
  50. return $this->hasOne(Category::class, 'id', 'cate_id')->where('type', 1)->field(['id', 'name'])->bind(['cate_name' => 'name']);
  51. }
  52. /**
  53. * 话术搜索
  54. * @param Model $query
  55. * @param $value
  56. */
  57. public function searchTitleAttr($query, $value)
  58. {
  59. if ($value !== '') $query->whereLike('title', '%' . $value . '%');
  60. }
  61. /**
  62. * 归属客服搜索
  63. * @param Model $query
  64. * @param $value
  65. */
  66. public function searchKefuIdAttr($query, $value)
  67. {
  68. if ($value !== '') {
  69. $query->where('kefu_id', $value);
  70. }
  71. }
  72. /**
  73. * 分类搜索
  74. * @param Model $query
  75. * @param $value
  76. */
  77. public function searchCateIdAttr($query, $value)
  78. {
  79. if ($value !== '') {
  80. $query->where('cate_id', $value);
  81. }
  82. }
  83. /**
  84. * @param Model $query
  85. * @param $value
  86. */
  87. public function searchMessageAttr($query, $value)
  88. {
  89. if ($value !== '') $query->where('message', $value);
  90. }
  91. }