'require', 'customer_id' => 'require', 'approve_id' => 'require', 'product' => 'require|array|checkProduct', ]; /** * 参数描述 * @var string[] */ protected $field = [ 'id' => 'id', ]; /** * @notes 添加场景 * @return QuotationValidate * @author likeadmin * @date 2023/11/27 17:23 */ public function sceneAdd() { return $this->remove('id', true); } /** * @notes 编辑场景 * @return QuotationValidate * @author likeadmin * @date 2023/11/27 17:23 */ public function sceneEdit() { return $this->only(['id', 'customer_id', 'approve_id', 'product']); } /** * @notes 删除场景 * @return QuotationValidate * @author likeadmin * @date 2023/11/27 17:23 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 详情场景 * @return QuotationValidate * @author likeadmin * @date 2023/11/27 17:23 */ public function sceneDetail() { return $this->only(['id']); } public function checkProduct($value, $rule, $data) { $firstData = $value[0] ?? []; if (empty($firstData['product_id'])) { return '产品ID不能为空!'; } if (empty($firstData['product_num'])) { return '产品数量不能为空!'; } if (empty($firstData['tax_rate'])) { return '产品税率不能为空!'; } return true; } }