DepartmentValidate.php 932 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\admin\validate;
  3. class DepartmentValidate extends BaseValidate
  4. {
  5. /**
  6. * 设置校验规则
  7. * @var string[]
  8. */
  9. protected $rule = [
  10. 'id' => 'require',
  11. 'name' => 'require|min:1',
  12. 'parent_id' => 'integer|min:0',
  13. 'weight' => 'require|integer|min:0',
  14. 'status' => 'integer|in:0,1',
  15. 'remark' => 'length:0,200',
  16. ];
  17. /**
  18. * 参数描述
  19. * @var string[]
  20. */
  21. protected $field = [
  22. 'id' => 'id',
  23. 'name' => '部门名称',
  24. 'parent_id' => '父部门ID',
  25. 'weight' => '权重',
  26. 'status' => '状态',
  27. 'remark' => '备注',
  28. ];
  29. /**
  30. * @notes 编辑场景
  31. */
  32. public function sceneEdit()
  33. {
  34. return $this->only(['name', 'parent_id', 'weight', 'status', 'remark']);
  35. }
  36. public function sceneId()
  37. {
  38. return $this->only(['id']);
  39. }
  40. }