Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么在提交注册表时会出现错误_Php_Laravel_Laravel Validation - Fatal编程技术网

Php 为什么在提交注册表时会出现错误

Php 为什么在提交注册表时会出现错误,php,laravel,laravel-validation,Php,Laravel,Laravel Validation,这是错误: 照亮\数据库\查询异常 SQLSTATE[42S22]:未找到列:在“where子句”(SQL:select count(*)中找到1054未知列“”,作为来自userswhere`=user@email.com) 我的重新注册控制器: use RegistersUsers; /** * Where to redirect users after registration. * * @var string */ protected $redirectTo = '/'; /

这是错误:

照亮\数据库\查询异常 SQLSTATE[42S22]:未找到列:在“where子句”(SQL:select count(*)中找到1054未知列“”,作为来自
users
where`=user@email.com)

我的重新注册控制器:

use RegistersUsers;

/**
 * Where to redirect users after registration.
 *
 * @var string
 */
protected $redirectTo = '/';

/**
 * Create a new controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest');
}

/**
 * Get a validator for an incoming registration request.
 *
 * @param  array  $data
 * @return \Illuminate\Contracts\Validation\Validator
 */
protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users,'],
        'password' => ['required', 'string', 'min:6', 'confirmed'],
    ]);
}

/**
 * Create a new user instance after a valid registration.
 *
 * @param  array  $data
 * @return \App\User
 */
protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
    ]);
}
} 我的用户表迁移:
您应该这样编写唯一规则,因为其中有一个逗号

'email' => ['unique:users',],
一个很好的替代方法是为此使用验证规则类,然后您将获得参数类型提示,并知道有哪些选项

'email' => [new Unique('users'),],

您应该这样编写唯一的规则,因为其中有一个逗号

'email' => ['unique:users',],
一个很好的替代方法是为此使用验证规则类,然后您将获得参数类型提示,并知道有哪些选项

'email' => [new Unique('users'),],

你好这个查询来自哪个部分的代码-选择count(*)作为usersHlw的聚合,我正在添加我项目的所有代码。。。请再次选中它。去掉验证规则中多余的逗号<代码>'unique:users',
投票支持以打字错误结束。Opps!谢谢,你好。这个查询来自哪个部分的代码-选择count(*)作为usersHlw的聚合,我正在添加我项目的所有代码。。。请再次选中它。去掉验证规则中多余的逗号<代码>'unique:users',投票支持以打字错误结束。Opps!谢谢