validate引发的报错 SQLSTATE[42S02]: Base table or view not found
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘frost.email’ doesn’t exist (SQL: select count(*) as aggregate from email
where email
= 63435173@qq.com)
我发现了validate会引发SQL的报错。然而这里没有注释的写法是来自laravel8中文文档。
public function login(Request $request)
{
$validated = $request->validate([
'email' => 'required|email|unique:email',
'password' => 'required|string|min:6|max:30',
]);
/* $this->validate($request, [
'email' => 'required|email',
'password' => 'required|min:6|max:30',
]); */
我发现使用注释掉的这段代码就不会报错,但是使用没有注释的代码,会报错。
unique 规则的格式是
unique:表名.字段名
,如果你查询的是users
表,则为users.email