gpt4 book ai didi

Laravel 通过数据库记录进行验证

转载 作者:行者123 更新时间:2023-12-02 21:24:38 25 4
gpt4 key购买 nike

Problem is how to validate by Database model, I have model "Emails". I just want to people can register if their email already in our Email model.

电子邮件数据库表

Schema::create('emails', function (Blueprint $table) {
$table->increments('id');
$table->text('username')->nullable();
$table->text('fullname')->nullable();
$table->text('description')->nullable();
$table->text('email')->nullable();
$table->timestamps();
});

Auth@RegisterController

protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|max:255|unique:users', here i guess
'password' => 'required|min:6|confirmed',
]);
}**strong text**

最佳答案

您必须使用unique验证 users 中的唯一电子邮件表和exists验证以检查 emails 中是否存在电子邮件表。

protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|max:255|unique:users|exists:emails',
'password' => 'required|min:6|confirmed',
]);
}

假设您有email领域 usersemails表格

关于Laravel 通过数据库记录进行验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51943786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com