I'm using itemId
instead of id
and when I validate as
'barcode' => 'required|unique:item,barcode,' .$this->get('itemId'),
I get
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select count(*) as aggregate from
item
wherebarcode
= 5391510260790 andid
<> 10)
How do I tell Laravel to use the itemId
instead of id
in the unique validation in the request class at the authorize()
function?
You can specify the column to check using the fourth parameter to the rule:
'barcode' => 'required|unique:item,barcode,'.$this->get('itemId').',itemId',