I have a form field which have unique validation. When I am trying to update the record it throws the unique validation error. The documentation mentioned to add the
->unique(ignoreRecord: true)
->unique(ignoreRecord: true)
but didn't helped. Anyone face this issue before? I also tried this
->unique(ignorable: fn ($record) => $record)
->unique(ignorable: fn ($record) => $record)
but same result.
Solution
I found what was the problem. So the $record somehow was null and that's why validated the unique every time. The workaround for this I passed the record from the Livewire component:
use Livewire\Component as Livewire;->unique(ignorable: fn (Livewire $livewire) => $livewire->record)
use Livewire\Component as Livewire;->unique(ignorable: fn (Livewire $livewire) => $livewire->record)