QuestionValidate.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\validate;
  3. class QuestionValidate extends BaseValidate
  4. {
  5. /**
  6. * 设置校验规则
  7. * @var string[]
  8. */
  9. protected $rule = [
  10. 'id' => 'require',
  11. 'category_id' => 'require|integer|min:0',
  12. 'question' => 'require|length:1,200',
  13. 'answer' => 'require|length:1,200',
  14. 'question_type' => 'require|integer',
  15. 'keyword_id' => 'integer|min:0',
  16. 'status' => 'integer|min:0',
  17. 'weight' => 'integer|min:0',
  18. ];
  19. /**
  20. * 参数描述
  21. * @var string[]
  22. */
  23. protected $field = [
  24. 'id' => 'id',
  25. 'category_id' => '分类ID',
  26. 'question_type' => '问题类别',
  27. 'question' => '问题',
  28. 'answer' => '回答',
  29. 'keyword_id' => '关键词ID',
  30. 'status' => '状态',
  31. 'weight' => '权重',
  32. ];
  33. /**
  34. * @notes 编辑场景
  35. */
  36. public function sceneEdit()
  37. {
  38. return $this->only([ 'category_id', 'question_type', 'question', 'answer', 'keyword_id', 'status', 'weight','language_code']);
  39. }
  40. public function sceneId()
  41. {
  42. return $this->only(['id']);
  43. }
  44. }