FilamentF
Filament3y ago
7 replies
low-res (Paul)

unique validation on soft-deleted records

Hi experts,
I have a simple form for users. The email address should be unique. The users Model uses soft-deletes.
The formfield for email looks like this:

TextInput::make('email')
    ->rules(['required', 'email'])
    ->unique( ignoreRecord: true )
    ->placeholder('Email')


This all works fine until I delete a user and want to create a new user with the same email as the deleted user.

In plain Laravel controller I could do something like:
'email' => 'unique:user,email,{$userId},id,deleted_at,NULL'

What would be the equivalent in my filament form?

Thx for help!
Was this page helpful?