Preventing Duplicate 'Active' Records in Model Using Filament
Hello, I'm new to using filament, how can I prevent a new record in my SchoolDiar model from being written if another record with 'active' with value 'Ativa' already exists?
4 Replies
The question is simply how to prevent a new entry if there's already another entry in the table with 'active' value 1.
Yes, but I need a query so that this exception is related to the current school. For example: school_id = 1. I need it to search the table for everything in the SchoolDiar model and check if there already exists one with 'active' value 'Ativa'.
Can we use a query in the unique() function for this?
maybe
modifyRuleUsing
. Check the docs.
You can also use a custom rule: https://filamentphp.com/docs/3.x/forms/validation#custom-rules