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

soogo's avatar
Level 1

verify and ignore unique input

this the correct way to verify and ignore unique input in a request?

public function rules()

{

$company = $this->route('company');

return ['company_name' => 'required|unique:companies,company_name',' . $company->id];

}

0 likes
4 replies
Snapey's avatar

what does the URI look like. Presumably containing the company id?

Snapey's avatar

if in your route, the parameter is {id} then

return ['company_name' => 'required|unique:companies,company_name,' . $this->id];

or, if its {company}

return ['company_name' => 'required|unique:companies,company_name,' . $this->company];
soogo's avatar
Level 1

I can't use $this->id/$this->company because it does not changed.

But $this->company->id work

Please or to participate in this conversation.