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
Post a Comment