Pasar datos a un cierre en Laravel 4
Estoy tratando de usar la clase Mail en Laravel 4, y no soy capaz de pasar variables al objeto m m.
El objeto team team contiene datos que tomé de la base de datos con eloquent.
Mail::send('emails.report', $data, function($m)
{
$m->to($team->senior->email, $team->senior->first_name . ' '. $team->senior->last_name );
$m->cc($team->junior->email, $team->junior->first_name . ' '. $team->junior->last_name );
$m->subject('Monthly Report');
$m->from('[email protected]', 'Sender');
});
Por alguna razón recibo un error donde el objeto team team no está disponible. Supongo que tiene algo que ver con el visor.
¿Alguna idea ?
93
1 answers
Si creó una instancia de la variable $team
fuera de la función, entonces no está en el ámbito de funciones. Creo que necesitas usar la palabra clave use.
$team = Team::find($id);
Mail::send('emails.report', $data, function($m) use ($team)
{
$m->to($team->senior->email, $team->senior->first_name . ' '. $team->senior->last_name );
$m->cc($team->junior->email, $team->junior->first_name . ' '. $team->junior->last_name );
$m->subject('Monthly Report');
$m->from('[email protected]', 'Sender');
});
209
Author: Blessing,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-11 04:26:34
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-11 04:26:34