Is this what you want? 1 - If during the edit, the user has changed their name, then include the unique validation 2 - If during the edit, the user has not changed their name, then don't include the unique validation
The document references an "except" on the unique validation. Would the following work?
public function update($id, Request $request) {
$this->validate($request, [
'name' => 'required|unique:customers,name,except,' . $id . '|min:3'
]);
$customer = Customer::findOrFail($id);
$customer->update($request->all());
return redirect('customers/'.$id);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community