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
如何发送密码设置(重置链接)laravel 7_Laravel_Laravel 7 - Fatal编程技术网

如何发送密码设置(重置链接)laravel 7

如何发送密码设置(重置链接)laravel 7,laravel,laravel-7,Laravel,Laravel 7,我试图向新创建的用户发送密码重置链接,但很难找到解决方案。如果有人有同样的问题,这里是什么工作为我在拉雷维尔7 还是有更好的方法来处理所有问题:在password_resets表中添加条目并发送通知? 邮件发送正确,但我想向用户发送密码重置邮件。下面是我的添加控制器 public function contactSave(Request $request) { $password = Hash::make($request->name); $va

我试图向新创建的用户发送密码重置链接,但很难找到解决方案。如果有人有同样的问题,这里是什么工作为我在拉雷维尔7

还是有更好的方法来处理所有问题:在password_resets表中添加条目并发送通知? 邮件发送正确,但我想向用户发送密码重置邮件。下面是我的添加控制器

public function contactSave(Request $request)
    {

        $password = Hash::make($request->name);

        $validate = $request->validate([
                        'name' => 'required|regex:/^[\pL\s\-]+$/u',
                        'email' => 'email',
                        'phone' => 'digits:10',
                        'address' => 'required',
                        'country' => 'required',
                        'state' => 'required',
                        // 'comment' => 'required',
                        'organization' => 'required',
                        'captcha' => 'required|captcha'
                    ],
                    [
                'captcha.captcha' => 'Incorrect Captcha'
            ]
                );

        $user= new User;
        $user->name = $request->name;
        $user->email = $request->email;     
        $user->password = $password;
        $user->save();


        $CustomerContact= new CustomerContact;

        // $CustomerContact->name = $request->name;
        // $CustomerContact->email = $request->email;
        $CustomerContact->phone = $request->phone;
        $CustomerContact->address = $request->address;
        $CustomerContact->user_id = $user->id;
        $CustomerContact->country_id = $request->country;
        $CustomerContact->state_id = $request->state;
        $CustomerContact->comment = $request->comment;
        $CustomerContact->organization = $request->organization;
        $CustomerContact->captcha = $request->captcha;

        $CustomerContact->save();

        $details = [
            'title' => 'Hi '.$request->name.'',
            'body' => 'Your account has been created successfully. Request you set your password with this link ???'
        ];
       
        \Mail::to($request->email)->send(new \App\Mail\ContactMail($details));

        return redirect('contacts')->with('success', 'User created successfully.');

        
    }  
有人来帮我吗。在用户和员工中保存数据后。我想发送带有密码重置链接的电子邮件到该用户id电子邮件($request->email)。
用kittle解释给我最简单的解决方案如何做到这一点

如果我正确理解了您的问题,您可以创建一个路由,例如:
password/reset/user code
并在电子邮件中发送给每个用户。 你应该为每个用户创建一个随机代码,当它被创建时,把它放在那个链接中,然后发送到你的电子邮件中。 当用户点击该链接时,它将到达您的控制器,您将检查数据库中的随机代码并找到您的用户!当您拥有您的用户时,您可以向他们显示重置密码和保存新密码的视图
如果您想向您的邮件发送一些数据(链接、令牌或其他所有内容),请使用以下命令:

Mail::to($request->email)->send(new ContactMail($your_token,$link,$user));
在ContactMail类中:

    class ContactMail extends Mailable
{
   
 use Queueable, SerializesModels;
    public $your_token;
    public $link;
    public $user;


public function __construct($your_token,$link,$user)
{
    $this->your_token= $your_token;
    $this->link= $link;
    $this->user= $user;
}


public function build()
{
    return $this->view('email')
        ->with('your_token',$this->your_token)
        ->with('link',$this->link)
        ->with('user',$this->user
}

}

是的,当用户创建带有url的邮件发送时,我使用默认身份验证。当url打开密码重置页面时,将打开令牌并保存以重置\u密码表。我是新来的。我不知道如何创建tokenid并向用户发送链接。也许这个链接可以帮助您:我知道创建的Token,但我将如何使用该密码链接发送欢迎消息?我不明白您的意思。当用户单击该链接时,它会转到某个函数,您可以在其中返回密码重置视图。你可以把你想要的任何东西传递到那个视图实际上我只怀疑如何用这个url和令牌发送邮件。我没有得到一个如何可以生成密码重置链接到邮件。我没有得到什么将是确切的网址。?在发送URL之前,我需要将该电子邮件nd令牌插入密码重置表,对吗?你解决了吗?@sta,没有,仍然没有得到任何解决方案。