Reputation: 1054
Hi guys i'm trying to mail on my system and there's problem on view which is undifined variable of data. i'm trying to parsing data to view, but it seems to be problem. here is my code of mailing
Mail::to($data['email'])->send(new TagihanMail(),['data' => $data]);
and here's my view
@component('mail::message')
# TAGIHAN PEMBAYARAN
Berikut tagihan anda untuk pembayaran
@component('mail::button', ['url' => ''])
{{ $data['nomor_tagihan'] }}
@endcomponent
@component('mail::table')
test
@endcomponent
Terimakasih,<br>
Panitia
@endcomponent
hope u guys can help me.
Upvotes: 1
Views: 1437
Reputation: 111829
You can use:
Mail::to($data['email'])->send(new TagihanMail($data));
and in your TagihanMail
you can use:
public function __construct($data)
{
$this->data = $data;
}
public function build()
{
return $this->view('your-view-here')->with(['data' => $this->data]);
}
Upvotes: 3
Reputation: 34914
Try to pass view name directly, like this.
Mail::to($data['email'])->send('emails.view_name',['data' => $data]);
Upate
You can pass data like this
$request = ['data' => $data];
Mail::to($data['email'])->send(new TagihanMail($request));
Upvotes: 0