'require|gt:0', 'content' => 'require|checkContent', ]; protected $message = [ 'id.require' => '参数错误', 'id.gt' => '参数错误', 'content.require' => '参数错误', ]; protected $scene = [ ]; protected function checkContent($value,$rule,$data=[]) { $content = json_decode($data['content'],true); if(!$content){ return '参数错误'; } $info = Db::name('pay_wages')->where('id',$data['id'])->find(); if(!$info){ return '参数错误'; } // if($info['company_id'] == 2 && $info['type'] == 3 && count($content) != 50){ // return '参数错误'; // } // if(($info['company_id'] == 1 || ($info['company_id'] == 2 && $info['type'] != 3)) && count($content) != 65){ // return '参数错误'; // } return true; } }