12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace app\common\validate;
- use think\Validate;
- use think\Db;
- class HouseContractPay extends Validate{
- protected $rule = [
- 'contract_id' => 'require',
- // 'sn|编号' => 'require|checkUnique',
- // 'intro|说明' => 'require',
- // 'pay_date|缴费时间' => 'require|date',
- ];
- protected $scene = [
- 'contract_id.require' => '参数错误'
- ];
- protected function checkUnique($value,$rule,$data=[])
- {
- $info = Db::name('house_contract_pay')->where('sn',$value)->where('del',0)->where('org_id',$data['org_id'])->find();
- if($data['id'] <= 0 && $info){
- return '编号已被使用';
- }
- if($info && $data['id'] > 0 && $info['id'] != $data['id']){
- return '编号已被使用';
- }
- return true;
- }
- }
|