在Laravel Markdown邮件的组件URL中使用变量 [英] Using a variable in component URL in laravel markdown mail
问题描述
我在Laravel中收到以下降价邮件:
I have the following markdown mail in Laravel:
# Welcome to Offer Site
Thanks for listing your product, {{$user->name}}!
@component('mail::button', ['url' => 'https://www.example.com/product/view/{{$product->id}}', 'color'=> 'orange'])
View it here
@endcomponent
但是,发送邮件时呈现的URL是https://www.example.com/product/view/%3C?php%20echo%20e(%24product-%3Eid);%20?%3E
However, the rendered URL when the mail is sent is https://www.example.com/product/view/%3C?php%20echo%20e(%24product-%3Eid);%20?%3E
这可能非常简单,但很难说...我该如何确保将变量作为参数正确插入到URL栏中,这是在ProductAdded
邮件的内部版本:>
This is probably super simple but its hard to word... how do I go about making sure the variable is properly inserted into the URL bar as the parameter, this is in the build of the ProductAdded
mail:
return $this->markdown('emails.product-added-email');
这就是我传递给ProductAdded
Mail:
And this is what I pass to ProductAdded
Mail:
\Mail::to($user)->send(new \App\Mail\ProductAdded($user, $product));
变量工作正常.
有什么想法吗?
推荐答案
您已经在php字符串中,无需使用刀片括号.您可以像这样连接字符串:
You are already inside a php string, there is no need to use the blade brackets. You can just concatenate the string like so:
@component('mail::button', ['url' => 'https://www.example.com/product/view/' . $product->id, 'color' => 'orange'])
这篇关于在Laravel Markdown邮件的组件URL中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!