laravel5.2工作,如何返回数据? [英] laravel5.2 job, how to return data?

查看:101
本文介绍了laravel5.2工作,如何返回数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class DataFormFields extends Job implements ShouldQueue
{
 use InteractsWithQueue, SerializesModels;

 protected $fieldList = [
        'name' => 'Tom',
        'age' => '20',
];
public function handle()
{
    $fields = $this->fieldList;

    return $fields;
}
}

控制器

public function create()
{
    $data = $this->dispatch(new DataFormFields());

    return view('create', $data);
}

我尝试dd($ data);打印0

I try to dd($data); print 0

该代码可以在laravel5.1中工作,但在5.2中则不行.帮助

the code can work in laravel5.1 ,but in 5.2 it's not ok.help

推荐答案

Laravel5.2该类将实现Illuminate\Contracts\Queue\ShouldQueue接口,从而向Laravel指示应将作业推送到队列中而不是同步运行. 所以你应该像php artisan make:job fooJob --sync

Laravel5.2 the class will implement the Illuminate\Contracts\Queue\ShouldQueue interface, indicating to Laravel that the job should be pushed onto the queue instead of run synchronously. So you should make job like php artisan make:job fooJob --sync

这篇关于laravel5.2工作,如何返回数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆