SubjectModel.class.php 773 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Admin\Model;
  3. use Think\Model;
  4. /**
  5. * 科目模型
  6. * @author Devil
  7. * @blog http://gong.gg/
  8. * @version 0.0.1
  9. * @datetime 2016-12-01T21:51:08+0800
  10. */
  11. class SubjectModel extends CommonModel
  12. {
  13. // 数据自动校验
  14. protected $_validate = array(
  15. // 添加,编辑
  16. array('name', 'CheckName', '{%common_name_format}', 1, 'callback', 3),
  17. array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
  18. array('sort', 'CheckSort', '{%common_sort_error}', 1, 'function', 3),
  19. );
  20. /**
  21. * [CheckName 科目名称校验]
  22. * @author Devil
  23. * @blog http://gong.gg/
  24. * @version 0.0.1
  25. * @datetime 2016-12-13T19:29:30+0800
  26. */
  27. public function CheckName()
  28. {
  29. $len = Utf8Strlen(I('name'));
  30. return ($len >= 2 && $len <= 16);
  31. }
  32. }
  33. ?>