rsusanto
2 years ago

Unique validation on 3 columns in 1 table

Posted 2 years ago by rsusanto

I found validator unique syntax and used it my project.

'size_value'=>'required|unique:sizes,size_value,NULL,NULL,size_metric,'.$request->size_metric

I used it, it's working fine, it validate unique of size_metric+size_value in sizes table. But i just don't understand few usage of few parameters.

1. sizes: table name
2. size_value: 1st request value checked against field column (size_value) 
3. NULL: ???,
4. NULL: ???,
5. size_metric: 2nd column
6. ,'.$request->size_metric: 2nd request value checked against 2nd column (size_metric)

Can somebody explain this validate unique syntax ? especially the 2 null

Can i make unique validation for 3 columns ? i will have a validation for product_id + size + colour

Really appreciate your thoughts guys, thank you.

Please sign in or create an account to participate in this conversation.