I think I've figured it out but do not really understand the syntax:
'required|unique:assessments,identifier,NULL,id,user_id,'.Auth::user()->id);'
I am not sure why I need NULL and id in there? It produces:
"select count(*) as aggregate from `assessments` where `identifier` = ? and `user_id` = ?"
From the Laravel docs on validation rules:
unique:table,column,except,idColumn
So, in your example, the third argument, NULL, is the except
bit. It's null because you're not trying to ignore a given ID. The fourth argument, if I read the docs right, is the column containing the id field... probably just id. The fifth and sixth arguments are what populate your where clause, in your example, WHERE user_id = Auth::user()->id
Again, from the docs for the third argument,
"Forcing A Unique Rule To Ignore A Given ID"
'email' => 'unique:users,email_address,10'
This is NOT working:
'short' => 'required|unique:kunden,id,6'
also tried: 'short' => 'required|unique:kunden,6'
since i cant find the information if i need to specify the field the 6 is related to or not.
I edit data with ID 6 and it still tells me i cant since short is existing already.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community