Laravel 8 Mail markdown keep using mail.default

122 Views Asked by At

We have been using the following code for over a year.

$data = [

   'date' => '11/11/11'

]

$notification = new Notification($data, "Hello", 'mail.account.report');

Redis::throttle('mail')->allow(3)->every(1)->then(function () {

Mail::to($this->to)

->cc($this->cc)

->bcc($this->bcc)

->send($notification);

});

class Notification extends Mailable

{

use Queueable, SerializesModels;



/**

* Create a new message instance.

*

* u/param array|string $data

* u/param string $subject

* u/param string $view

*/

public function __construct($data, $subject, $view = 'mail.default')

{

$this->from("[email protected]", "name app")

->subject($subject)->markdown($view, ['data' => $data]);

/*

I can do this and it fails too:$this->from("[email protected]", "name app")

->subject($subject)->markdown('mail.account.report', ['data' => $data]);

*/

}



/**

* Build the message.

*

* u/return $this

*/

public function build()

{

   return $this;

}
}

report.blade.php:

@component('mail::message')

<p>

Hello,

</p>

<p>

Here is the Usage Charges Monthly Report for {{$data['date']}}.

</p>

<p>

Thank you,<br>

{{ config('app.name') }}

</p>

@endcomponent

Suddenly after qa refresh and uploading the new code (that it have nothing to with this part), it breaks everything and we got the following error:

ErrorException: Array to string conversion in /home/vagrant/code/spa/storage/framework/views/bc2af11cf69fdbc969ddfe1141a2edf90a22e7d0.php:4


{

"view":

{

"view":

   "/home/vagrant/code/spa/resources/views/mail/default.blade.php",

"data":

{

"data":

   "<pre class=sf-dump id=sf-dump-607141657 data-indent-pad=" "><span class=sf-dump-note>array:1</span> [<samp data-depth=1 class=sf-dump-expanded> "<span class=sf-dump-key>date</span>" => "<span class=sf-dump-str title="10 characters">June, 2023</span>" </samp>] </pre><script>Sfdump("sf-dump-607141657", {"maxDepth":3,"maxStringLength":160})</script> ",

   "email":

"<pre class=sf-dump id=sf-dump-148194488 data-indent-pad=" ">"<span class=sf-dump-str title="18 characters">[email protected]</span>" </pre><script>Sfdump("sf-dump-148194488", {"maxDepth":3,"maxStringLength":160})</script> ",

   "name":

"<pre class=sf-dump id=sf-dump-1328756938 data-indent-pad=" ">"<span class=sf-dump-str title="3 characters">APP</span>" </pre><script>Sfdump("sf-dump-1328756938", {"maxDepth":3,"maxStringLength":160})</script> ",

"connection":

"<pre class=sf-dump id=sf-dump-1446501493 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1446501493", {"maxDepth":3,"maxStringLength":160})</script> ",

"queue":

"<pre class=sf-dump id=sf-dump-1784612767 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1784612767", {"maxDepth":3,"maxStringLength":160})</script> ",

"chainConnection":

"<pre class=sf-dump id=sf-dump-1964405443 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1964405443", {"maxDepth":3,"maxStringLength":160})</script> ",

"chainQueue":

"<pre class=sf-dump id=sf-dump-1958693155 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1958693155", {"maxDepth":3,"maxStringLength":160})</script> ",

"chainCatchCallbacks":

"<pre class=sf-dump id=sf-dump-1857918802 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1857918802", {"maxDepth":3,"maxStringLength":160})</script> ",

"delay":

"<pre class=sf-dump id=sf-dump-1603919039 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1603919039", {"maxDepth":3,"maxStringLength":160})</script> ",

"afterCommit":

"<pre class=sf-dump id=sf-dump-1924264995 data-indent-pad=" "><span class=sf-dump-const>null</span> </pre><script>Sfdump("sf-dump-1924264995", {"maxDepth":3,"maxStringLength":160})</script> ",

"middleware":

"<pre class=sf-dump id=sf-dump-1040229917 data-indent-pad=" ">[] </pre><script>Sfdump("sf-dump-1040229917", {"maxDepth":3,"maxStringLength":160})</script> ",

"chained":

"<pre class=sf-dump id=sf-dump-1091641362 data-indent-pad=" ">[] </pre><script>Sfdump("sf-dump-1091641362", {"maxDepth":3,"maxStringLength":160})</script> "

}

}

}

I don't know what the error is. Markdown continues using the default view, not the report view.

Please help

thank you

0

There are 0 best solutions below