Unique rule not working on update

Hello,

I have this unique rule:

  TextInput::make('item_code')
      ->label('Artikelcode')
      ->required()
      ->maxLength(255)
      ->rule(function (Get $get) {
          return Rule::unique('products', 'item_code')
              ->where(fn ($query) => $query->where('brand_id', $get('brand_id')))
              ->ignore(request()->route('record'));
      }),

However when updating the record i also get the error message that it is not unique.

This shouldn't be the case. How can I make this rule only validate on creating records and not on updating records?
Solution
I figured it out. I had extra code in the creating and updating hooks off my model which interfered with the validation logic
Was this page helpful?