I have a simple form which posts to a controller which checks if a name for an item is already taken for a particular project. If it is, then it returns an error. This is th
For add record
'name' => [
'required',
'string',
'min:3',
Rule::unique('products')->where(function ($query) {
return $query->where('store_id', Auth::user()->store_id);
})->whereNull('deleted_at'),
],
For edit that record
'name' => [
'required',
'string',
'min:3',
Rule::unique('products')->where(function ($query) {
return $query->where('store_id', Auth::user()->store_id);
})->ignore($request->id, 'id')->whereNull('deleted_at'),
],