I still can't find a resolution to this problem.
Can anyone help?
Hello!
I've got a problem with Validation. I've googled for an answer, but the only option I saw (doesn't relate directly to my issue) requires me to create my own Validation rule, which seems like overkill?
I have a table with two columns which need to be Unique.
When creating the record, the validation works fine.
When I try to Update, the 'Abbreviation' field shows as duplicate.
public function update(Request $request, Film $film)
{
//
$this->validate($request, [
'name' => 'required|min:3|unique:"films", "name", ' . $film->id ,
'abbreviation' => 'required|max:5|unique:"films", "abbreviation", ' . $film->id,
'type_id' => 'required|numeric|filled',
]);
$film = new Film;
$film->name = $request->name;
$film->abbreviation = $request->abbreviation;
$film->type_id = $request->type_id;
$film->save();
return redirect()->route( 'films.index' )->with('message', 'Successfully updated Film.');
}
What's happening? What am I doing wrong?
Thank you!
Serge
also, I think your unique rule is a bit off. It should all be in a single string instead of multiple strings. Something like '...unique:films,abbreviation,'.$film->id,
Please or to participate in this conversation.