English 中文(简体)
用户信息更新过程中的Laravel电子邮件确认问题
原标题:Laravel email validation issue during user information update

I m 相对较新,而I ve 则陷入一个问题。 当用户把自己的信息输入我的系统时,我想绕过电子邮件的确认。 具体来说,他们没有发现电子邮件已经使用错误。 Im利用请求管理数据更新。

相关法典:

public function rules(): array
{
    $userId = $this->input( id );
    $userEmail = $this->input( email );

    return [
         name  =>  required ,
         surname  =>  required ,
         id  =>  required ,  numeric ,  min_digits:8 ,  max_digits:8 ,
         tin  => [ required ,  numeric ,  min_digits:11 ,  max_digits:11 , new ValidateDniTinMatch],
         date_of_birth  =>  required|date|before_or_equal:  . now()->format( d-m-Y ),
         email  => [
             required ,
             unique:owners,email, .$userEmail,
            Rule::unique( owners )->ignore($userEmail)
        ],
         mobile_phone  =>  required ,
         alternative_mobile_phone  =>  nullable|different:phone_number ,
         address  =>  required ,
         city  =>  required ,
         province  =>  required ,
         country  =>  required ,
         zip_code  =>  required|numeric ,
    ];
}

在我在线研究以及Laravel文献中,我找到了解决这一问题的两个潜在解决办法:

Rule::unique( owners )->ignore($userEmail)

and

 unique:owners,email, .$userEmail

As you can see in the code I provided, I ve tried both:

 email  => [
     required ,
     unique:owners,email, .$userEmail,
    Rule::unique( owners )->ignore($userEmail)
],

然而,这两种解决办法都没有奏效。 我不敢确定什么是尝试的,我感到有点损失。

问题回答

这可能是因为使用<代码>ignore方法不正确。 <代码>ignore 方法应当通过用户的身份证,您希望从独特的支票而不是电子邮件中排除。

public function rules(): array
{
    $userId = $this->input( id );

    return [
         name  =>  required ,
         surname  =>  required ,
         id  =>  required ,  numeric ,  min_digits:8 ,  max_digits:8 ,
         tin  => [ required ,  numeric ,  min_digits:11 ,  max_digits:11 , new ValidateDniTinMatch],
         date_of_birth  =>  required|date|before_or_equal:  . now()->format( d-m-Y ),
         email  => [
             required ,
            Rule::unique( owners )->ignore($userId,  id )
        ],
         mobile_phone  =>  required ,
         alternative_mobile_phone  =>  nullable|different:phone_number ,
         address  =>  required ,
         city  =>  required ,
         province  =>  required ,
         country  =>  required ,
         zip_code  =>  required|numeric ,
    ];
}

在上述代码中,我先将<代码>用户/代码>改为$userId载于ignore。 这告诉Laravel公司在检查独一无二的电子邮件时,忽视了该身份证的使用者。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签