截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MenuDecorateValidate.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\admin\validate\decoration;
  20. use app\common\basics\Validate;
  21. use app\common\enum\MenuEnum;
  22. class MenuDecorateValidate extends Validate{
  23. protected $rule = [
  24. 'id' => 'require',
  25. 'name' => 'require|unique:menu_decorate,name^del^decorate_type',
  26. 'image' => 'require',
  27. 'menu' => 'checkMenu',
  28. 'sort' => 'integer|gt:0'
  29. ];
  30. protected $message = [
  31. 'id.require' => '请选择菜单',
  32. 'name.require' => '请输入菜单名称',
  33. 'name.unique' => '菜单名称重复',
  34. 'image.unique' => '请上传图标',
  35. 'sort.integer' => '排序值须为整型',
  36. 'sort.gt' => '排序值须大于0',
  37. ];
  38. public function sceneAdd(){
  39. return $this->remove('id',['require']);
  40. }
  41. public function sceneEdit(){
  42. return $this->remove('id',['require']);
  43. }
  44. public function sceneDel(){
  45. return $this->only(['id']);
  46. }
  47. public function sceneSwtich(){
  48. return $this->only(['id']);
  49. }
  50. public function checkMenu($value,$rule,$data){
  51. if( 1 == $data['link_type']){
  52. $menu_list = MenuEnum::INDEX;
  53. if(2 == $data['type']){
  54. $menu_list = MenuEnum::CENTRE;
  55. }
  56. $menu_index = array_column($menu_list,'index');
  57. if(!in_array($value,$menu_index)) {
  58. return '菜单不存在';
  59. }
  60. }else{
  61. if(empty($value)){
  62. return '请输入自定义链接';
  63. }
  64. }
  65. return true;
  66. }
  67. }