QuestionValidate.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. 'question_id' => 'integer|min:0',
  12. 'category_id' => 'integer|min:0',
  13. 'question' => 'require|length:1,200',
  14. 'answer' => 'require|length:1,200',
  15. 'question_type' => 'require|integer',
  16. 'keyword_id' => 'integer|min:0',
  17. 'status' => 'integer|min:0',
  18. 'weight' => 'integer|min:0',
  19. ];
  20. /**
  21. * 参数描述
  22. * @var string[]
  23. */
  24. protected $field = [
  25. 'id' => 'id',
  26. 'question_id' => 'question_id',
  27. 'category_id' => '分类ID',
  28. 'question_type' => '问题类别',
  29. 'question' => '问题',
  30. 'answer' => '回答',
  31. 'keyword_id' => '关键词ID',
  32. 'status' => '状态',
  33. 'weight' => '权重',
  34. ];
  35. /**
  36. * @notes 编辑场景
  37. */
  38. public function sceneEdit()
  39. {
  40. return $this->only(['question_id', 'category_id', 'question_type', 'question', 'answer', 'keyword_id', 'status', 'weight','language_code']);
  41. }
  42. public function sceneId()
  43. {
  44. return $this->only(['id']);
  45. }
  46. }