StoreServiceSpeechcraft.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. declare (strict_types=1);
  12. namespace app\model\message\service;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 客服话术
  18. * Class StoreServiceSpeechcraft
  19. * @package app\model\message\service
  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. * @param Model $query
  47. * @param $value
  48. */
  49. public function searchTitleAttr($query, $value)
  50. {
  51. $query->whereLike('title', '%' . $value . '%');
  52. }
  53. /**
  54. * 归属客服搜索
  55. * @param Model $query
  56. * @param $value
  57. */
  58. public function searchKefuIdAttr($query, $value)
  59. {
  60. if ($value !== '') {
  61. $query->where('kefu_id', $value);
  62. }
  63. }
  64. /**
  65. * 分类搜索
  66. * @param Model $query
  67. * @param $value
  68. */
  69. public function searchCateIdAttr($query, $value)
  70. {
  71. if ($value !== '') {
  72. $query->where('cate_id', $value);
  73. }
  74. }
  75. /**
  76. * @param Model $query
  77. * @param $value
  78. */
  79. public function searchMessageAttr($query, $value)
  80. {
  81. if ($value) {
  82. $query->where('message', $value);
  83. }
  84. }
  85. }