我的 Laravel 验证有问题。
在数组上调用成员函数 failed()
Symfony\Component\Debug\Exception\FatalThrowableError 抛出消息“调用成员函数失败()在数组上”
堆栈跟踪:
`#0 Symfony\Component\Debug\Exception\FatalThrowableError in C:\laragon\www\frontine\app\Http\Controllers\authController.php:37
public function postRegister(Request $request)
{
$query = $this->validate($request, [
'user' => 'string|required|unique:users|min:4|max:24',
'email' => 'email|string|required|unique:users',
'pass' => 'string|required|min:8',
'cpass' => 'string|required|min:8|same:pass',
'avatar' => 'image|mimes:jpeg,jpg,png|max:2048',
]);
if ($query->fails())
{
return redirect('/registrar')
->withErrors($query)
->withInput();
}
}
Run Code Online (Sandbox Code Playgroud)