php - 带参数的 Laravel 电子邮件模板路由
问题描述
我使用 Laravel 创建了一个简单的电子邮件功能,用户收到一封电子邮件,在该电子邮件中我想调用一个下载文件的路由。
我的可邮寄:
class AppSent extends Mailable
{
use Queueable, SerializesModels;
public $name = '';
public function __construct(String $name)
{
$this->name = $name;
}
public function build()
{
return $this->from(env('MAIL_USERNAME'))
->markdown('emails.download.android_app');
}
}
单击按钮时,我在 DownloadController 中调用此函数,该函数会向用户发送电子邮件:
return Mail::to($request->email)->queue(new AppSent($request->name));
这是用户获得的降价视图(电子邮件视图):
@component('mail::message')
Hi,
Downloadlink created
@component('mail::button', ['url' => 'https://myapp.com/download'])
Download!
@endcomponent
@endcomponent
这是我需要调用以下载 zip 文件的路线:
public function download(Request $request)
{
return response()->download(
storage_path('/app/uploaded_apps/' . $request->name . '.zip')
);
}
如何在我的下载刀片视图中添加参数以下载具有给定名称的特定文件?
解决方案
您可以在 url 数组中添加参数:
@component('mail::message')
Hi,
Downloadlink created
@component('mail::button', ['url' => 'https://myapp.com/download', 'name' => $name])
Download!
@endcomponent
@endcomponent
推荐阅读
- python - 带有 std::function 的 cpyy
) 打回来 - python - 仅在可被范围整除时测试并返回数字
- php - Laravel 漂亮的 URL srt_replace 不起作用
- google-cloud-platform - 通过邮递员调用 Google API
- pascal - 取消 ReadLn 输入读数
- php - 将 foreach 生成的内容添加到数组中
- reactjs - 将创建反应应用程序部署到 Google 云的最佳方式是什么?
- security - Spring WebFlux URL Matching:区分路径和路径变量
- c# - 提取 Windows 中任何文件的缩略图 - C# - PDF
- c# - 对话框不是函数弹出表单