Repeater with 2 Unique Key Combinations
Good morning, I have a case where a course has a cost based on a "mode" and "type". Initially, it was based only on the "mode", and this code in
CourseResource
worked perfectly:
But after adding the "type", I get errors when saving, errors when disabling the selects for the unique combination of types and modes, etc.
My question is: Is there an established or standard way to handle the Repeater with 2 unique key combinations?
Before:
courses(id, name)
modes(id, name)
costs(id, [course_id, mode_id] unique, cost)
Now:
courses(id, name)
modes(id, name)
types(id, name)
costs(id, [course_id, mode_id, type_id] unique, cost)
2 Replies
Add a unique to each of the Select & Text with a debounce on the ->live() and check each value.
https://filamentphp.com/docs/3.x/forms/validation#unique
Add a compute column to the table, and use that