I'm trying to pass data from my controller to mail class but it won't work for some reasons.
Problem should be somewhere in variable passing but I don't have any error messages.
Controller code:
$send_data = [
"name" => $product->name,
"quantity" => $item->quantity,
"price" => $final_price
];
\Mail::to($email)->send(new OrderMail($send_data));
Mail class:
class OrderMail extends Mailable
{
use Queueable, SerializesModels;
public $subject = "Úspešná objednávka";
public $send_data;
public function __construct($send_data)
{
$this->send_data = $send_data;
}
public function build()
{
$send_data = $this->send_data;
return $this->markdown('emails.ordered');
}
I would like to access data in emails.ordered view