Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mohammedawni's avatar

First value is repeated for each query of nested array validation !

The rule is

'val.*.bond_row_id' => [
                'required',
                Rule::exists('general-data.rased_eftetahies', 'id')->where(function (Builder $query) {
                    return $query->where('branch_code_id', $this->def_branch)
                        ->where('product_code', $this->input('val.*.product_code'))
                        ->where('insertion_num', $this->input('val.*.insertion_num'));
                }),
            ],

The query is

select count(*) as aggregate from `rased_eftetahies` where `id` = '40381' and (`branch_code_id` = '1' and `product_code` = '263' and `insertion_num` = '92')

select count(*) as aggregate from `rased_eftetahies` where `id` = '40382' and (`branch_code_id` = '1' and `product_code` = '263' and `insertion_num` = '92')

But insertion_num should be in the second query 93 instead of 92

select count(*) as aggregate from `rased_eftetahies` where `id` = '40381' and (`branch_code_id` = '1' and `product_code` = '263' and `insertion_num` = '92')

select count(*) as aggregate from `rased_eftetahies` where `id` = '40381' and (`branch_code_id` = '1' and `product_code` = '263' and `insertion_num` = '93')

and the request is

0 likes
0 replies

Please or to participate in this conversation.