-1
I have a problem validating the Unique field. My problem before was q if I was going to update the value I didn’t edit, because I was accusing q the value was Japanese, I solved it, but now it doesn’t validate the Unique field, but updates kkk
This is my Request - I’ve tried these 3 methods and they only let me update the field! It doesn’t validate if the value is unique before sending it to the bank!
public function rules()
{
return[/*'nome'=>'bail|required|min:3|max:250|',Rule::unique('service')->ignore($this->service),*/
'nome'=> 'bail|required|min:3|max:250|unique:service,nome,'.$this->id.',id',
/*'nome' => 'bail|required|min:3|max:250',Rule::unique('service','nome')->ignore($this->service),*/
'observacao'=> 'required'
];
}
Now my Controller
public function create()
{
$action = route('admin.service.store');
return view('admin.cadastro.service',compact('action'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(ServiceRequest $request)
{
Service::create($request->all());
return redirect()->route('admin.gerencial.index')->with('success_message', 'Cadastrado com Sucesso');
}
I’ve tried several ways and I can’t do it! I need help!