簡體   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

我的驗證方法:

    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!");
}

驗證通知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

}}

發布通知和郵件資源:

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

並使用您的自定義模板編輯 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

以前版本的 Laravel 通常提供的前端腳手架已被提取到 laravel/ui Composer package 中。

所以首先安裝 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