'integer|>=:0', 'pid' => 'integer|>=:0', 'page' => 'integer|>:0', 'page_size' => 'integer|between:1,50', 'order_by' => 'in:pid,id,createtime,updatetime,rand', 'order_way' => 'in:asc,desc', 'has_picture' => 'integer|in:0,1', 'order_id' => 'require|integer|>:0', 'remark' => 'require|array', 'remark.*.goods_id' => 'require|integer|>:0', 'remark.*.star' => 'require|integer|between:1,5', 'remark.*.content' => 'require|max:500', 'remark.*.images' => 'array', 'evaluate_status' => 'integer|in:1,2,3', 'comment_id' => 'require|integer|>:0', ]; protected $message = [ 'goods_id.integer' => '商品ID必须为整数', 'pid.integer' => '父评论ID必须为整数', 'page.integer' => '页码必须为正整数', 'page_size.between' => '每页显示条数必须在1-50之间', 'order_by.in' => '排序字段不正确', 'order_way.in' => '排序方式不正确', 'has_picture.in' => '是否有图片参数错误', 'order_id.require' => '订单ID不能为空', 'order_id.integer' => '订单ID必须为整数', 'remark.require' => '评论内容不能为空', 'remark.array' => '评论内容格式不正确', 'remark.*.goods_id.require' => '商品ID不能为空', 'remark.*.goods_id.integer' => '商品ID必须为整数', 'remark.*.star.require' => '评分不能为空', 'remark.*.star.between' => '评分必须在1-5之间', 'remark.*.content.require' => '评论内容不能为空', 'remark.*.content.max' => '评论内容不能超过500字', 'remark.*.images.array' => '图片格式不正确', 'evaluate_status.in' => '评价状态参数错误', 'comment_id.require' => '评论ID不能为空', 'comment_id.integer' => '评论ID必须为整数', ]; protected $scene = [ 'index' => ['goods_id', 'pid', 'page', 'page_size', 'order_by', 'order_way', 'has_picture'], 'add' => ['order_id', 'remark', 'pid'], 'myList' => ['page', 'page_size'], 'stats' => ['goods_id'], 'audit' => ['comment_id', 'evaluate_status'], ]; /** * 验证评价状态 * @param $value * @param $rule * @param $data * @return bool|string */ public function checkEvaluateStatus($value, $rule, $data) { if (!CommentEnum::isValidEvaluateStatus($value)) { return '评价状态参数错误'; } return true; } /** * 验证有图片状态 * @param $value * @param $rule * @param $data * @return bool|string */ public function checkHasPicture($value, $rule, $data) { if (!CommentEnum::isValidHasPicture($value)) { return '有图片状态参数错误'; } return true; } }