New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unique validation error while updating using form request #10
Comments
Hi, Before I start bug hunting: any chance it has something to do with using If not, I'll try to reproduce it in a test. 👍 |
like this |
It worked after updating the rule,route and function like below. 'name.*' => 'required|string|min:1|max:255|unique_translation:service_categories,name,' . $this->id, web.php(route file) Route::put('service_category/{id}', 'ServiceCategoriesController@update')
->name('service_categories.service_category.update')->where('id', '[0-9]+'); controller public function update($id, ServiceCategoriesFormRequest $request)
{
....
} but why your example not working? |
Hi, In PHP you can do this: $str = "A string containing a {$variable}"; But not this (single quotes around the string): $str = 'A string containing a {$variable}'; So this should work for you: 'name.*' => "required|string|min:1|max:255|unique_translation:service_categories,name,{$this->serviceCategory->id}", |
I form for saving the category. The name field is unique. I'm using
FormRequest
for validating the form. Create works fine. but while updating getting error showingThe name.en has already been taken.
form fields
FormRequest.php
web.php (route file)
controller.php
The text was updated successfully, but these errors were encountered: