email - Laravel 5: passing variable into subject -


i using laravel's mail class , pass variable subject. here code:

public function send() {     $offer = offer::find($id)->toarray();      mail::send('offermail', $offer, function($message) {         $message->to('some@email.com');         $message->subject('offer no.' . $offer['code']);     }); } 

i getting

undefined variable: offer 

within line subject defined.

don't forget inject outer variables closure's scope.

mail::send('offermail', $offer, function($message) use ($offer) {     $message->to('some@email.com');     $message->subject('offer no.' . $offer['code']); }); 

you can see examples under example 3 section in here.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -