我在验证request
中的controller
时遇到了麻烦。我使用exists
验证规则。用户应该提交integer
。此整数应在id
表的单行中以user_courses
形式存在。此行还应使列user_id
等于158
- docs。
我的验证规则:
'course_id' => 'integer|exists: user_courses, id, user_id, 158'
取而代之的是:
Connection.php第333行中的PDOException:SQLSTATE [42S22]:列不是 发现:1054'where子句'中的未知列'id'
我的表:
id, user_id, created_at, updated_at
答案 0 :(得分:1)
问题在于空间:
'course_id' => 'integer|exists: user_courses, id, user_id, 158' // incorrect
'course_id' => 'integer|exists:user_courses,id,user_id,158' // correct
原始代码会混淆laravel来搜索这样的列名:
' user_courses'