'require|max:1024', 'user_code|用户' => 'require|length:32', 'url|图片文件地址' => 'length:0,255', 'type|类型' => 'require|checkType', 'lng|定位信息' => 'require', 'lat|定位信息' => 'require', 'location|位置信息' => 'length:0,200', ]; protected $scene = [ 'edit_password' => ['old_password', 'password', 'confirm_password'], //修改密码 ]; protected function checkType($value,$rule,$data=[]) { return isset(CommentModel::allType()[$value]) ? true : '评论类型错误'; } }