Laravel:第342行上的非法字符串偏移“文件",文件Illuminate/Mail/Mailable.php [英] Laravel: Illegal string offset 'file' on line 342, file Illuminate/Mail/Mailable.php

查看:98
本文介绍了Laravel:第342行上的非法字符串偏移“文件",文件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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆