I'm running Laravel 5.6 and I have the following rules in my request:
[
'tabs' => 'array|required',
'tabs.*.id' => 'exists:order_tabs,id',
'tabs.*.number' => Rule::unique('order_tabs', 'number')->ignore('tabs.*.id')
]
I want the unique to ignore the id that has been passed with the data inside the same array.
For example, my payload would look something like this:
[
'tabs' => [
[
'id' => 1,
'number' => '123123'
],
[
'id' => 2,
'number' => '123124'
]
]
]
However, when I run the following, I still get the unique rule failure. I think it's not parsing the tabs.*.id that I'm passing as a parameter.
I could loop through each of my payload, and generate the rules, but I'm wondering if there's another way to do it.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2jMkc94
via IFTTT
Aucun commentaire:
Enregistrer un commentaire