No puedo acceder a los datos en la vista de correo electrónico

I have a problem with email's views with Laravel. This is how I send a mail:

$user = $bet->user; // A bet hasOne user. All is ok here

Mail::queue('emails.betWon', array('user' => $user), function($message) use ($user)
    $message->to($user->email)->subject('Tu as remporté un pari !');

Esta es mi vista emails.betWon:

<!DOCTYPE html>
    <html lang="fr">
        <meta charset="utf-8">
        {{ var_dump($user) }}

And this is the mail I get:

array (size=3)
  'timestamps' => boolean false
  'incrementing' => boolean true
  'exists' => boolean true

Which is not a User object...

preguntado el 28 de mayo de 14 a las 14:05

1 Respuestas

Because you are using Mail::queue you cannot send an object to the queue, as data is being serialized. You need to convert it to an array first.


$user = $bet->user;


$user = $bet->user->toArray();

contestado el 28 de mayo de 14 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.