KefuLangValidate.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\validate\kefu;
  20. use app\common\model\KefuLang;
  21. use app\common\validate\BaseValidate;
  22. /**
  23. * 客服话术验证器
  24. * Class KefuLangValidate
  25. * @package app\adminapi\validate\kefu
  26. */
  27. class KefuLangValidate extends BaseValidate
  28. {
  29. protected $rule = [
  30. 'id' => 'require|checkLang',
  31. 'title' => 'require|unique:' . KefuLang::class . ',title',
  32. 'content' => 'require|unique:' . KefuLang::class . ',content',
  33. 'sort' => 'egt:0',
  34. ];
  35. protected $message = [
  36. 'title.require' => '请输入标题',
  37. 'title.unique' => '标题已存在',
  38. 'content.require' => '请输入内容',
  39. 'content.unique' => '内容已存在',
  40. 'sort.egt' => '排序不能小于零',
  41. ];
  42. public function sceneAdd()
  43. {
  44. $this->remove('id', true);
  45. }
  46. public function sceneDel()
  47. {
  48. $this->only(['id']);
  49. }
  50. public function checkLang($value, $rule, $data)
  51. {
  52. $lang = KefuLang::findOrEmpty($value);
  53. if ($lang->isEmpty()) {
  54. return '话术不存在';
  55. }
  56. return true;
  57. }
  58. }