Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a variable in component URL in laravel markdown mail

Tags:

php

email

laravel

I have the following markdown mail in Laravel:

# Welcome to Offer Site
Thanks for listing your product, {{$user->name}}! 

@component('mail::button', ['url' => 'https://www.example.com/product/view/{{$product->id}}', 'color'=> 'orange'])
View it here
@endcomponent

However, the rendered URL when the mail is sent is https://www.example.com/product/view/%3C?php%20echo%20e(%24product-%3Eid);%20?%3E

This is probably super simple but its hard to word... how do I go about making sure the variable is properly inserted into the URL bar as the parameter, this is in the build of the ProductAdded mail:

return $this->markdown('emails.product-added-email');

And this is what I pass to ProductAdded Mail:

\Mail::to($user)->send(new \App\Mail\ProductAdded($user, $product));

The variables work fine.

Any ideas?

like image 591
iLC Avatar asked Dec 24 '22 17:12

iLC


1 Answers

You are already inside a php string, there is no need to use the blade brackets. You can just concatenate the string like so:

@component('mail::button', ['url' => 'https://www.example.com/product/view/' . $product->id, 'color' => 'orange'])
like image 140
Jerodev Avatar answered Feb 21 '23 07:02

Jerodev