UserSalary.php 946 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\index\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class UserSalary extends Validate
  6. {
  7. protected $rule = [
  8. 'salary|基本工资' => 'require|gt:0',
  9. 'month|月份' => 'require',
  10. 'uaid' => 'require|gt:0|checkUaid',
  11. 'days' => 'require|gt:0',
  12. 'real_days' => 'require|gt:0',
  13. ];
  14. protected $message = [
  15. 'salary.gt' => '基本工资必须大于0',
  16. 'uaid.checkUaid' => '本月已添加记录',
  17. 'days.gt' => '应出勤天数必须大于0',
  18. 'real_days.gt' => '实际出勤天数必须大于0',
  19. ];
  20. protected $scene = [
  21. ];
  22. protected function checkUaid($value,$rule,$data){
  23. $map['uaid'] = $data['uaid'];
  24. $map['month'] = $data['month'];
  25. $ret = Db::name('user_salary')->where($map)->find();
  26. if($ret && $ret['id'] == $data['id']){
  27. return true;
  28. }
  29. return $ret?false:true;
  30. }
  31. }