I have subject tables and fields are standard_id, stream_id, medium_id, board_id, subject_name and many others.
I want to add Rule unique for subject_name which is unique for standard_id, stream_id, medium_id, board_id fields.
$validator = Validator::make( $inputs,
[
'v_name' => [
'required',
Rule::unique( 'tbl_subject' )->ignore( $id, 'id' ),
],
],
[
'v_name.required' => 'Name is required',
'unique' => 'Name address already exits.',
]
);
Example
standard_id, stream_id, medium_id, board_id subject_name
1 2 1 3 A
3 2 4 1 B
1 3 1 4 c
Validation like if subject_name "A" unique for 1, 2, 1, 3. B unique for 3, 2, 4, 1. But subject_name "A" not unique for 2,2,1,3 and so on..
subject_nameofAfor the1, 2, 1, 3combination of inputs? Are those inputs in your request as well? Try implementing something like what is mentioned in Adding additional where clauses