Unique with soft delete

public function up(): void { Schema::create('brands', function (Blueprint $table) { $table->id(); $table->string('name'); $table->mediumText('description')->nullable(); $table->softDeletes(); // This line adds the soft delete functionality $table->timestamps(); $table->unique('name','deleted_at'); }); } i am trying to have unique name but i also have soft delete is there is any way ???
2 Replies
Chrispian
Chrispian12mo ago
FYI, This is core Laravel functionality and not specific to Filament. So it really depends on your use case and why/what you want to happen. But you could add an observer and change the uniuqe name of the soft deleted user. There's a really good write up on how to do that here: https://dev.to/mmollick/using-unique-columns-and-soft-deletes-in-laravel-470p We use soft deletes on email but we don't allow people to sign up twice. In our user flow what we do is reactivate their account by removing the deleted_at. Hope that helps.
GHOST-117
GHOST-11712mo ago
i did some thing like this