MenuValidate.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\admin\validate;
  3. class MenuValidate extends BaseValidate
  4. {
  5. /**
  6. * 设置校验规则
  7. * @var string[]
  8. */
  9. protected $rule = [
  10. 'id' => 'require',
  11. 'name' => 'require|length:1,50',
  12. 'parent_id' => 'integer|min:0',
  13. 'type' => 'require|integer|in:1,2',
  14. 'icon' => 'length:0,100',
  15. 'perms' => 'length:0,100',
  16. 'paths' => 'length:0,100',
  17. 'component' => 'length:0,100',
  18. 'params' => 'length:0,100',
  19. 'sort' => 'integer|min:0',
  20. 'is_cache' => 'integer|in:0,1',
  21. 'status' => 'integer|in:0,1',
  22. ];
  23. /**
  24. * 参数描述
  25. * @var string[]
  26. */
  27. protected $field = [
  28. 'id' => 'id',
  29. 'name' => '菜单名称',
  30. 'parent_id' => '父菜单ID',
  31. 'type' => '菜单类型',
  32. 'icon' => '图标',
  33. 'perms' => '权限',
  34. 'paths' => '路径',
  35. 'component' => '组件',
  36. 'params' => '参数',
  37. 'sort' => '排序',
  38. 'is_cache' => '是否缓存',
  39. 'status' => '状态',
  40. ];
  41. /**
  42. * @notes 编辑场景
  43. */
  44. public function sceneEdit()
  45. {
  46. return $this->only(['name', 'parent_id', 'type', 'icon', 'perms', 'paths', 'component', 'params', 'sort', 'is_cache', 'status']);
  47. }
  48. public function sceneId()
  49. {
  50. return $this->only(['id']);
  51. }
  52. }