laravel队列作业alwasy失败

时间:2020-02-18 11:37:54

标签: laravel-queue

我想使用Laravel队列作业的帽子, 这是我的工作代码

class PostComment implements ShouldQueue

{ 使用Dispatchable,InteractsWithQueue,Queueable,SerializesModels;

/**
 * Create a new job instance.
 *
 * @return void
 */
public function __construct($comments)
{
    $this->comments = $comments;
}

/**
 * Execute the job.
 *
 * @return void
 */
public function handle(Request $request)
{
    // $this->comments->create($request->all());

    $findNews = News::find($id);
    if($findNews){
        $comments = Comment::create($this->comments);
        return $comments;
}
// 
}

这是我的控制器

  public function postComment($request,$id)
    {
        $findNews = $this->news->find($id);
        if($findNews){
            $comments = $this->comments->create([
                'content'   => $request->content,
                'user_id'   => auth()->user()->id,
                'news_id'   => $findNews->id,
            ]);
            PostComment::dispatch($comments);
            return response()->json([
                'Message'   => 'Comment succesfull',
                'data'      => $comments,
            ]);

        }
    }

但是当我运行 php artisan:queue工作

工作失败了

enter image description here

我的代码有什么问题?

0 个答案:

没有答案