F
Filament14mo ago
Gush

Not allow identic records

How do i not allow user to create records with the same values of existing ones exemple: brand_id->1 model_id->2 i cant pass ->unique() to each field because that would only allow to have one of each
3 Replies
Saade
Saade14mo ago
you mean, the user cannot create a record with brand_id 1 and model_id 1 if it already exists on the database? but he can create lets say brand_id 1 and model_id 2 ?
Gush
GushOP14mo ago
exacly that
Saade
Saade14mo ago
your case its a bit diff from the other post you need a unique based on two columns in your migration, add $table->unique(['brand_id', 'model_id']) and on your resource, create a custom rule https://filamentphp.com/docs/3.x/forms/validation#custom-rules https://laraveldaily.com/post/laravel-unique-validation-multiple-columns
Want results from more Discord servers?
Add your server