Serializing Eloquent models can be a bit complicated. The safest way is to simply pass the identifier to the Mail queue and receive it when it returns:
$data = ['user_id' => 1];
Mail::later(5,'email.template', $data, function ($message) {
...
});
And in your template (above):
<?php $user = User::find($user_id); ?>
.. rest of template
Or, as some other people on IRC suggest, skip Mail::later()altogether and use Queue::later()instead. Write your own handler that extracts the models from the identifiers and then launches Mail::send().
source
share