Document.php 631 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class Document extends Validate{
  6. protected $rule = [
  7. 'title|文档名称' => 'require',
  8. 'cate_id|文档分类' => 'require|gt:0',
  9. 'auth' => 'checkAuth',
  10. ];
  11. protected $message = [
  12. 'cate_id.gt' => '未选择文档分类',
  13. 'cate_id.require' => '未选择文档分类',
  14. ];
  15. protected $scene = [
  16. ];
  17. protected function checkAuth($value,$rule,$data=[])
  18. {
  19. if($value === 3 && !$data['auths']){
  20. return '未选择查看范围';
  21. }
  22. return true;
  23. }
  24. }