Search code examples
laravelmarkdownhtml-emaillaravel-5.7

Dynamic basic link in mail markdown with Laravel - not a button


I can generate a basic link like so:

This is an [example link](http://example.com/).

I can generate a button with a dynamic link like so:

@component('mail::button', ['url' => \URL::to('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=subscribe')])
Sign Me Up
@endcomponent

But how do I generate a dynamic link, not button?

I tried:

[Safe Unsubscribe]( url('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=unsubscribe') )

and

[Safe Unsubscribe]( \URL::to('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=unsubscribe') )

but these output in a literal way:

url('/subscriptions/'.%24recipient-%3Eid.'/'.%24recipient-%3Eemail.'?action=subscribe%27)

Solution

  • You are still in a blade template. So if you are not in a blade directive and you want to echo content, you have to use the curly brackets.

    [Safe Unsubscribe]({{ url('/subscriptions/'.$recipient->id.'/'.$recipient->email.'?action=unsubscribe') }})