第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel 自定義驗證通知報錯

Laravel 自定義驗證通知報錯

PHP
料青山看我應(yīng)如是 2022-12-11 09:06:13
我正在嘗試更新 Laravel 中的驗證電子郵件通知。我試圖在 AppServiceProvider 中生成驗證鏈接,然后將鏈接傳遞給通知類,但后來它給了我一個錯誤,即“未定義屬性 ::$view”。應(yīng)用服務(wù)提供商/**     * Bootstrap any application services.     *     * @return void     */    public function boot()    {        VerifyEmail::toMailUsing(function ($notifiable) {             $verificationUrl = URL::temporarySignedRoute(                'verification.verify',                Carbon::now()->addMinutes(config('auth.verification.expire', 60)),                [                    'id' => $notifiable->getKey(),                    'hash' => sha1($notifiable->getEmailForVerification()),            )            return new EmailVerification($verificationUrl);        });    }驗證郵箱<?phpnamespace App\Notifications;use Illuminate\Bus\Queueable;use Illuminate\Contracts\Queue\ShouldQueue;use Illuminate\Notifications\Messages\MailMessage;use Illuminate\Notifications\Notification;class EmailVerification extends Notification implements ShouldQueue{    use Queueable;    public $verificationUrl;    /**     * Create a new notification instance.     *     * @return void     */    public function __construct($verificationUrl)    {        $this->verificationUrl = $verificationUrl;    }    /**     * Get the notification's delivery channels.     *     * @param  mixed  $notifiable     * @return array     */    public function via($notifiable)    {        return ['mail'];    }    /**     * Get the mail representation of the notification.     *     * @param  mixed  $notifiable     * @return \Illuminate\Notifications\Messages\MailMessage     */    public function toMail($notifiable)    {        $verificationUrl = $this->verificationUrl;        return (new MailMessage)                        ->subject('Please verify your email')                        ->markdown('emails.verification', ['url' => $verificationUrl]);    }   
查看完整描述

1 回答

?
精慕HU

TA貢獻(xiàn)1845條經(jīng)驗 獲得超8個贊

本教程對此進(jìn)行了很好的解釋。

https://brabeum.com/2019/10/customise-the-laravel-user-verification-email/


您應(yīng)該首先在用戶模型中覆蓋在用戶注冊時發(fā)送通知的默認(rèn)函數(shù)。


/app/User.php


/**

 * Override the default function that send a notification to verify

 * the email after a new user register.

 *

 */

  public function sendEmailVerificationNotification()

  {

     $this->notify(new Notifications\UserVerificationEmail);

  }

然后創(chuàng)建自定義通知:


/app/Notifications/EmailVerification.php.


<?php


namespace App\Notifications;


use Illuminate\Bus\Queueable;

use Illuminate\Contracts\Queue\ShouldQueue;

use Illuminate\Notifications\Messages\MailMessage;

use Illuminate\Notifications\Notification;

use Illuminate\Support\Carbon;

use Illuminate\Support\Facades\Config;

use Illuminate\Support\Facades\URL;


class UserVerificationEmail extends Notification

{

    use Queueable;


    /**

     * Create a new notification instance.

     *

     * @return void

     */

    public function __construct()

    {

        //

    }


    /**

     * Get the notification's delivery channels.

     *

     * @param  mixed  $notifiable

     * @return array

     */

    public function via($notifiable)

    {

        return ['mail'];

    }


    /**

     * Get the mail representation of the notification.

     *

     * @param  mixed  $notifiable

     * @return \Illuminate\Notifications\Messages\MailMessage

     */

    public function toMail($notifiable)

    {

        return (new MailMessage)

        ->subject('Please verify your email address')

        ->markdown(

            'emails.userverify', 

            [

               'url' => $this->verificationUrl($notifiable),

               'notifiable' => $notifiable,

            ]

        );

    }


    /**

     * Get the array representation of the notification.

     *

     * @param  mixed  $notifiable

     * @return array

     */

    public function toArray($notifiable)

    {

        return [

            //

        ];

    }


    /*

   * Build the verification URL

   *

   * @return URL

   */

   protected function verificationUrl($notifiable)

   {

      return URL::temporarySignedRoute(

         'verification.verify',

         Carbon::now()->addMinutes(

            Config::get('auth.verification.expire', 60)),

              [

                'id' => $notifiable->getKey(),

                'hash' => sha1($notifiable->getEmailForVerification()),

              ]     

         ); 

   }

}

然后是可郵寄模板:


/resources/views/emails/userverify.blade.php


@component('mail::message')

# Welcome {{ $notifiable->name }}


Before you can use this tutorial system you must verify your email address.


@component('mail::button', ['url' => $url])

Brabeum Verify Email Address Tutorial

@endcomponent


If you did not create an account, no further action is required.

Thanks,


{{ config('app.name') }} Team


@component('mail::subcopy')

If you’re having trouble clicking the "Verify Email Address" button, copy and paste the URL below into your web browser: {{ $url }} 

@endcomponent


@endcomponent


查看完整回答
反對 回復(fù) 2022-12-11
  • 1 回答
  • 0 關(guān)注
  • 125 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號