SalaryYear.php 732 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class SalaryYear extends Validate{
  6. protected $rule = [
  7. 'year|年份' => 'require',
  8. ];
  9. protected $message = [
  10. 'year.require' => '未选择年份',
  11. ];
  12. protected $scene = [
  13. ];
  14. protected function checkYear($value,$rule,$data=[]){
  15. $map[] = ['user_id','=',$data['user_id']];
  16. $map[] = ['year','=',$data['year']];
  17. $map[] = ['del','=',0];
  18. if($data['id'] > 0){
  19. $map[] = ['id','<>',$data['id']];
  20. }
  21. $ret = Db::name('salary_year')->where($map)->find();
  22. if($ret){
  23. return '该年份已提交过记录';
  24. }
  25. return true;
  26. }
  27. }