ConfigValidate.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\admin\validate;
  3. class ConfigValidate extends BaseValidate
  4. {
  5. /**
  6. * 设置校验规则
  7. * @var string[]
  8. */
  9. protected $rule = [
  10. 'id' => 'require',
  11. 'field' => 'require|length:1,50',
  12. 'val' => 'require|length:0,2000',
  13. 'remark' => 'length:0,100',
  14. 'weight' => 'integer',
  15. 'flag' => 'require|in:0,1,2,3,4',
  16. 'type' => 'require',
  17. ];
  18. /**
  19. * 参数描述
  20. * @var string[]
  21. */
  22. protected $field = [
  23. 'id' => 'id',
  24. 'field' => '参数名',
  25. 'val' => '参数值',
  26. 'remark' => '备注',
  27. 'weight' => '权重',
  28. 'type' => '类型',
  29. 'flag' => '标志',
  30. 'unit' => '单位',
  31. 'language_code' => '语言代码',
  32. ];
  33. /**
  34. * @notes 编辑场景
  35. */
  36. public function sceneAdd()
  37. {
  38. return $this->only(['field', 'val', 'remark', 'weight', 'type', 'flag', 'unit', 'language_code']);
  39. }
  40. /**
  41. * @notes 编辑场景
  42. */
  43. public function sceneEdit()
  44. {
  45. return $this->only(['id', 'val', 'remark', 'language_code']);
  46. }
  47. public function sceneId()
  48. {
  49. return $this->only(['id']);
  50. }
  51. }