Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 序列化';关闭';发送排队邮件时不允许_Laravel_Laravel 4 - Fatal编程技术网

Laravel 序列化';关闭';发送排队邮件时不允许

Laravel 序列化';关闭';发送排队邮件时不允许,laravel,laravel-4,Laravel,Laravel 4,问题在于将闭包传递给Mail::queue。发生了什么?这与所做的完全相同。好吧,我假设$attributes是您试图传递到电子邮件视图欢迎的内容。如果是,则需要将其放入数组中。在这种情况下,应该是这样的: Log::info('Sending email', array( 'title' => $attributes['title'], 'recipient' => $attributes['email'] )); Mail::queue('emails.welc

问题在于将闭包传递给
Mail::queue
。发生了什么?这与所做的完全相同。

好吧,我假设
$attributes
是您试图传递到电子邮件视图
欢迎的内容。如果是,则需要将其放入数组中。在这种情况下,应该是这样的:

Log::info('Sending email', array(
    'title' => $attributes['title'],
    'recipient' => $attributes['email']
));

Mail::queue('emails.welcome', $attributes, function($message) use ($attributes)
{
    $message
        ->to($attributes['email'])
        ->subject($attributes['title']);
});

。。。这可能对你有用!:我遇到了相同的错误消息。我的问题是我的$attributes是一个雄辩的模型,我想它是不可序列化的。我必须改变:

Mail::队列('emails.welcome',数组('attributes'=>$attributes),函数($message)使用($attributes)

$attrray=$attributes->toArray();

邮件::队列('emails.welcome',数组('attributes'=>$attributes),函数($message)use($attrray)

我知道这篇文章很旧,但我最近也遇到了这个错误。原因是在邮件队列回调中放入了一个$request实例

Mail::queue('emails.welcome', array('attributes' => $attributes), function($message) use ($attributes)
{
    $message
        ->to($attributes['email'])
        ->subject($attributes['title']);
});
Mail::queue('emails.welcome',$data,function()){

$email=$request->input('email');//问题是在闭包中使用$this。请查看文件SerializableClosures.php和函数serialize()。
$this->to和$this->subject是类上的字段引用,而不是闭包中的字段引用,因此要修复代码,您必须使它们成为局部变量并将它们传递给闭包。

您的
$attributes
变量中有什么?它是否包含
分页器
对象?您能
var\u dump
吗?这是确切的错误吗?'Seri“Closure'not allowed'?我现在如何访问这些属性?@Fractaliste…因为它是一个数组,事实上是这样的!:d
'attributes'
键在视图中成为变量名。为了参数起见,我有这个
数组('atrr'=>$attributes)
,然后我必须在视图中调用它们,这样
$atrr['email']
。明白了吗?好的,键变成了一个变量名。我认为
$data=array('attr'=>'anything')
应该在视图中使用
$data['attr']
Mail::queue('emails.welcome',$data,function(){

$email = $request->input('email'); // <- apparently this will cause a closure error


});