Is it possible to use "unique together" in Laravel, similarly to Django?
So in Django you can do this:
unique_together = ('name', 'username',) so if you try to register people like this:
- name: John, username: blabla <---- this gets registered
- name: John, username: haha <---- this gets registered
- name: John, username: blabla <---- this won't get registered because the combination of John and blabla already exists.
Is the something similar is Laravel I could use?
The main goal is to check if the name with the username exists together, if it does, throw back a validation error, otherwise register the record to the database.
edit #1: if I can get something like "unique together" in laravel, is it possible to modify the validation method based on a hidden field in the form?
For example I want the user to write their name and email and submit it, and have a checkbox. The checkbox would enable/disable the 'unique' check of the name, so like if I do this:
name: John Doe Corp. email: whatever, checkbox: Ticked
then it would check the 'name' column for duplicates. Otherwise:
name: Jane Doe. email: whatever, checkbox: Not Ticked
then it would not check the name column for duplicates, allowing the record to be saved into the database.