Make row unique on 2 columns

I have a user_reports table that contains a user_id and report_name. I'm creating a select and I want each user to only have 1 entry for a given report, ie they should not have the same report listed twice for the same user. I'm using a Relation Manager to achieve this, but when I add ->required() to the field it won't allow me to create a record for a different user, shows a message saying 'The report has already been taken'. Hoping this makes sense and someone can help with this.
Solution:
As a stopgap, I've any options that are already used set as disabled in the select by using ->disableOptionWhen() and querying for the user and report name. This works as a stopgap as it's the only place in the application where a report can be added to a user but clearly not all that flexible and doesn't use the validation logic
Jump to solution
1 Reply
Solution
Mark Railton
Mark Railton11mo ago
As a stopgap, I've any options that are already used set as disabled in the select by using ->disableOptionWhen() and querying for the user and report name. This works as a stopgap as it's the only place in the application where a report can be added to a user but clearly not all that flexible and doesn't use the validation logic
Want results from more Discord servers?
Add your server