简体   繁体   English

laravel 6 中的自定义邮件验证模板

[英]Custom mail verification template in laravel 6

I want to customize the default laravel email verification message with a custom html template, I tried different solution but either working only in laravel 5 or the verification button is not working, I followed this tutorial: https://medium.com/@pran.81/how-to-implement-laravels-must-verify-email-feature-in-the-api-registration-b531608ecb99 I want to customize the default laravel email verification message with a custom html template, I tried different solution but either working only in laravel 5 or the verification button is not working, I followed this tutorial: https://medium.com/@pran .81/how-to-implement-laravels-must-verify-email-feature-in-the-api-registration-b531608ecb99

My verify method:我的验证方法:

    public function verify(Request $request)
{
    $userID = $request['id'];
    $user = User::findOrFail($userID);
    $date = date("Y-m-d g:i:s");
    $user->email_verified_at = $date; // to enable the “email_verified_at field of that user be a current time stamp by mimicing the must verify email feature
    $user->save();
    return response()->json("Email verified!");
}

The verification notification class:验证通知class:

class VerifyApiEmail extends VerifyEmailBase{

protected function verificationUrl($notifiable)
{
    return URL::temporarySignedRoute(
        'verificationapi.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
    ); // this will basically mimic the email endpoint with get request

}}

Publish the notification and mail resources:发布通知和邮件资源:

php artisan vendor:publish --tag=laravel-notifications
php artisan vendor:publish --tag=laravel-mail

And Edit resources/views/notifications/email.blade.php with your custom template并使用您的自定义模板编辑 resources/views/notifications/email.blade.php

In previous version Laravel 6.0 after make:auth you will see email template at resources/views/auth/verify.blade.php With Laravel 6.0 From changelog In previous version Laravel 6.0 after make:auth you will see email template at resources/views/auth/verify.blade.php With Laravel 6.0 From changelog

The frontend scaffolding typically provided with previous releases of Laravel has been extracted into a laravel/ui Composer package.以前版本的 Laravel 通常提供的前端脚手架已被提取到 laravel/ui Composer package 中。

So firstly install laravel ui and ui:install所以首先安装 laravel ui 和 ui:install

composer require laravel/ui  "^1.2" --dev
php artisan ui:auth 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM