Oct 22, 2020
0
Level 1
How to validate pivot table for unique key value pair?
I have a three tables... first
image -> id, name, timestampe
second
tag -> id, name, timestampe
Image and tag has many to many relation and also have a pivot table
tag_image -> tag_id, image_id
I want to validate the user tag request as they are unique or not... My code so far
$request->validate([
'tags' => [
'bail',
'required',
'string',
'unique:image_tag,image_id,tag_id'
]
]);
Problem is user sending ajax request as $request->tags but the unique method needs their ids
Please or to participate in this conversation.