Laravel:第342行上的非法字符串偏移“文件",文件Illuminate/Mail/Mailable.php [英] Laravel: Illegal string offset 'file' on line 342, file Illuminate/Mail/Mailable.php
问题描述
我正在尝试使用Laravel的attachFromStorageDisk
方法将一些文档附加到电子邮件中,该方法已在文档中阅读:邮件-Laravel .
public function build()
{
$email = $this->view('emails.message')
->subject($this->emailSubject);
foreach ($this->attachments as $attachment) {
$email->attachFromStorageDisk('filemanager', $attachment);
}
return $email;
}
我得到的错误是这个Illegal string offset 'file' on line 342, file Illuminate/Mail/Mailable.php
,我想不出一种解决办法.
$this->attachments
是一个数组,其中包含我要附加到电子邮件的文件的路径,并且所有路径都是正确的.
你们知道如何解决这个问题吗?我在第342行Mailable.php中找不到关于此特定错误的很多信息.
谢谢!
将变量$this->attachments
的名称更改为其他名称
可发送邮件的类已经具有您要覆盖的属性$attachments
.
I am trying to attach some documents to an email, using Laravel's attachFromStorageDisk
method, that I read about in the documentation: Mail - Laravel.
public function build()
{
$email = $this->view('emails.message')
->subject($this->emailSubject);
foreach ($this->attachments as $attachment) {
$email->attachFromStorageDisk('filemanager', $attachment);
}
return $email;
}
And the error I'm getting is this Illegal string offset 'file' on line 342, file Illuminate/Mail/Mailable.php
and I can't figure out a way to fix this.
$this->attachments
is an array containing the paths to the files I want to attach to the e-mail, and all the paths are correct.
Do you guys have any idea how to solve this? I couldn't find much about this specific error on line 342, Mailable.php
Thanks!
Change the name of your variable $this->attachments
to something else
Mailable class already has property $attachments
, which you are overwriting.
这篇关于Laravel:第342行上的非法字符串偏移“文件",文件Illuminate/Mail/Mailable.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!