BookValidate.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\admin\validate\life;
  3. use think\Validate;
  4. class BookValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'life_book_name' => 'require|max:20',
  8. 'life_book_id' => 'require',
  9. 'life_book_title' => 'require',
  10. 'life_book_time' => 'require',
  11. 'life_book_category_id' => 'require',
  12. 'life_book_teacher_id' => 'require',
  13. 'life_book_num' => 'require',
  14. 'life_book_img' => 'require',
  15. 'life_book_status' => 'require',
  16. 'life_book_type' => 'require',
  17. ];
  18. protected $message = [
  19. 'life_book_id.require' => '课程ID不能为空',
  20. 'life_book_name.require' => '课程名称不能为空',
  21. 'life_book_title.require'=> '课程简介不能为空',
  22. 'life_book_time.require' => '课程时间不能为空',
  23. 'life_book_name.max' => '课程名称不能超过20字',
  24. 'life_book_category_id.require' => '课程分类不能为空',
  25. 'life_book_teacher_id.require' => '课程教师不能为空',
  26. 'life_book_num.require' => '上课人数不能为空',
  27. 'life_book_img.require' => '课程图片不能为空',
  28. 'life_book_status.require' => '课程状态不能为空',
  29. 'life_book_type.require' => '课程类型不能为空',
  30. ];
  31. //场景
  32. protected $scene = [
  33. 'create' => ['life_book_name','life_book_title','life_book_time','life_book_category_id','life_book_teacher_id','life_book_num','life_book_type','life_book_status','life_book_img'],
  34. 'update' => ['life_book_id','life_book_name','life_book_title','life_book_time','life_book_category_id','life_book_teacher_id','life_book_num','life_book_type','life_book_status','life_book_img'],
  35. 'info' => ['life_book_id']
  36. ];
  37. }