I got an input that contains an array of objects. Now I'd like to validate it, but one part of the validation depends on another item of the object, so I need it's index:
[
'items.myarray.*.owner_id' => 'numeric|exists:App\Models\Owner',
'items.myarray.*.key' => ['nullable', 'string', 'min:20', 'max:20', 'exists:App\Models\Invitation,key',
new KeyIsValid(Owner::findOrFail(request()->input('items.*.owner_id')))],
];
Of course request()->input('items.myarray.*.owner_id') is not working - but I am looking for a way to pass the owner_id of the current object to this validation.