2017-06-15 56 views
0

我在Laravel以下降價郵件:在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 

但是,當郵件被髮送呈現的網址是https://www.example.com/product/view/%3C?php%20echo%20e(%24product-%3Eid);%20?%3E

這可能是超級簡單但它很難...我怎麼去確保變量正確地插入到URL欄中作爲參數,這是在ProductAdded的內部版本:

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

而這正是我傳給ProductAdded郵件:

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

變量做工精細。

任何想法?

回答

2

你已經在一個php字符串中,不需要使用刀片括號。你可以像這樣連接字符串:

@component('mail::button', ['url' => 'https://www.example.com/product/view/' . $product->id, 'color' => 'orange']) 
+0

啊,就是這樣,對不起,我知道它會是這樣的。感謝你的幫助Jerodev! (當SO讓我時,生病了) – iLC