1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class SalaryYear extends Validate{
- protected $rule = [
- 'year|年份' => 'require',
- ];
- protected $message = [
- 'year.require' => '未选择年份',
- ];
- protected $scene = [
- ];
- protected function checkYear($value,$rule,$data=[]){
- $map[] = ['user_id','=',$data['user_id']];
- $map[] = ['year','=',$data['year']];
- $map[] = ['del','=',0];
- if($data['id'] > 0){
- $map[] = ['id','<>',$data['id']];
- }
- $ret = Db::name('salary_year')->where($map)->find();
- if($ret){
- return '该年份已提交过记录';
- }
- return true;
- }
- }
|