Created
April 15, 2015 15:12
-
-
Save rdgutierrez/7ddf1c97157ed5baf1fd to your computer and use it in GitHub Desktop.
Pasando variables a la vista de un email y al closure en Laravel 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Metes la data en un array $data | |
| $data = array( | |
| 'name'=>$contactName, | |
| 'email'=>$contactEmail, | |
| 'message'=>$contactMessage | |
| ); | |
| En tu plantilla "view" podras usar estas variables | |
| {{ $name }} | |
| {{ $email }} | |
| {{ $message }} | |
| Y en tu controlador trabajas así: | |
| $contactName = Input::get('name'); | |
| $contactEmail = Input::get('email'); | |
| $contactMessage = Input::get('message'); | |
| $data = array('name'=>$contactName, 'email'=>$contactEmail, 'message'=>$contactMessage); | |
| Mail::send('template.mail', $data, function($message) use ($contactEmail, $contactName) | |
| { | |
| $message->from($contactEmail, $contactName); | |
| $message->to('info@domain.com', 'myName')->subject('Mail via domainh.com'); | |
| }); | |
| Al closure se le estan pasando los datos asi: | |
| use ($contactEmail, $contactName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment