Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

milar's avatar
Level 1

The name has already been taken.

I am in the edit form. I want to update the form. when I updated this form. I get this message.

The name has already been taken.

public function rules(): array
{
    return [
        'name' => [
            'required',
            'string',
            Rule::unique('permissions')->ignore($this->id),
        ]
    ];
}

}

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

What is $this->id; probably not the ID of the Permission instance you are updating? If you are using Route-Model binding and the URL wildcard is {permission}, try this instead:

Rule::unique('permissions')->ignore($this->route('permission')),

Otherwise, replace 'permission' with whatever the wildcard is, e.g. $this->route('id')

1 like
Snapey's avatar

what is the route ? Does it have an {id} element?

Please or to participate in this conversation.