Answer the question
In order to leave comments, you need to log in
How to make Validator unique on soft delete?
Hello!
Added soft deletion of users. It works, but unique doesn't care about the deleted_at column.
'email' => 'required|email|unique:users,email',
Is it possible to somehow add a condition to it to skip email when the deleted_at field is not null.
Or will you have to delete this rule and make a query to the database yourself for the search?
Answer the question
In order to leave comments, you need to log in
The rule works as it should. Imagine what will happen if you restore a deleted user, and E-mail is busy.
You need soft-deleted users after a certain period of time to delete forever.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question