简体   繁体   中英

How can i send data to markdown laravel?

I'm using laravel notification for send verification email to users.

This is my toMail function in VerifyEmailNotification :

public function toMail($notifiable)
{
    $verificationUrl = $this->verificationUrl($notifiable);

    if (static::$toMailCallback) {
        return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
    }

    return (new MailMessage)
        ->subject('Verification Email')
        ->markdown('emails.verify-email', ['url' => $verificationUrl]);
}

And this is my markdown view :

@component('mail::message')

<p>Verification link : </p>

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

<p>{{ env('APP_NAME') }}</p>

@endcomponent

As you can see i pass $verificationUrl to Markdown view, But when i click on send verificaion link, i got this error :

Undefined variable: verificationUrl (View: D:\Web\projects\pi\resources\views\emails\verify- 
email.blade.php)

Why i have this error and what can i do ?

在这里,您将变量 $verificationUrl 传递给 markdown 并将其命名为 url,因此您应该通过调用 $url 而不是 $verificationUrl 来访问它

markdown('emails.verify-email', ['url' => $verificationUrl]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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