如何验证模型具有自定义ID的唯一电子邮件。这是我的更新验证规则
'email' => 'required|unique:accounts,email,' . $user->account_id,
但是这失败并出现sql错误Unknown column 'id' in 'where clause'
id应为account_id
这是尝试的查询
select count(*) as aggregate from `accounts` where `email` = test@test.com and `id` <> 2445
答案 0 :(得分:1)
进行一些研究我发现以下内容将在自定义索引上验证作为规则的唯一要求
public Integer deleteincomeData(String _id) {
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(TABLE_NAME2, "_id = ?", new String[]{_id});
}
答案 1 :(得分:0)
'email' => 'required|unique:accounts,email,'.$user->account_id.',my_custom_user_id'
指定您要更改的表的ID。通常是自定义ID。