UserLableValidate.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\user;
  20. use app\common\{
  21. model\UserLabel,
  22. model\UserLabelIndex,
  23. validate\BaseValidate,
  24. };
  25. /**
  26. * 会员标签验证器
  27. * Class UserLableValidate
  28. * @package app\adminapi\validate\user
  29. */
  30. class UserLableValidate extends BaseValidate
  31. {
  32. protected $rule = [
  33. 'id' => 'require',
  34. 'ids' => 'require',
  35. 'name' => 'require|max:32|unique:'.UserLabel::class.',name',
  36. 'label_type' => 'require|in:0,1',
  37. ];
  38. protected $message = [
  39. 'id.require' => '请选择标签',
  40. 'ids.require' => '请选择标签',
  41. 'name.require' => '请输入标签名称',
  42. 'name.max' => '标签名称最多为32个字符',
  43. 'name.unique' => '标签名称已存在',
  44. 'label_type.require' => '请选择标签类型',
  45. 'label_type.in' => '标签类型错误',
  46. ];
  47. //商品添加验证
  48. public function sceneAdd()
  49. {
  50. return $this->remove(['id'=>'require','ids'=>'require']);
  51. }
  52. public function sceneDel(){
  53. return $this->only(['ids']);
  54. // ->append('ids','checkLable');
  55. }
  56. public function sceneEdit()
  57. {
  58. return $this->remove(['ids'=>'require']);
  59. }
  60. // public function checkLable($value,$rule,$data){
  61. //
  62. // $user = UserLabelIndex::where(['label_id'=>$value])->select()->toArray();
  63. //
  64. // if($user){
  65. // $labelIds = array_column($user,'label_id');
  66. // $labelName = UserLabel::where(['id'=>$labelIds])->column('name');
  67. // return implode('、',$labelName).'标签已有用户使用,无法删除';
  68. // }
  69. // return true;
  70. // }
  71. }