Im trying to update a record in the database, and im using Form Request to validate unique fields, but I cant pass the id to that Form because im just using the route like this:
Route::resource('ganado/engorde', 'GanadoController')->middleware('auth');
In my update controller:
public function update(GanadoEditFormRequest $request, $id)
{
$bovino = Ganado::findOrFail($id);
...
}
This is my form request:
public function rules()
{
return [
'codigo_ganado' => ['required',
Rule::unique('ganado')
->ignore($this->id, 'id_ganado')
->where('lote_actual', $this->lote_actual)
->where('ganaderia', $this->ganaderia)
],
];
}
I tried to pass directly the id = "85" just to check if this "ignore" thing its working and im getting and error too=
id <> 85 instead of id = 85.
How I can ignore the current updating record the right way?
Edit:
This is my "Ganado" table:
