Laravel队列:不允许“关闭”的作业序列化

时间:2018-08-23 18:27:58

标签: php laravel laravel-5 queue

我已经尝试解决thisthis的问题,最后,它们不能解决我的问题。

我像这样将作业添加到队列中

public function successPayment(Request $request){

$command = Command::findOrFail($request->reference);

if($command->state == Command::PENDING){
        $command->state = Command::SUCCESS;
        $command->payed_at = now();

        if(!empty($oldCommandItem = session('renew_command')))
        {
            $commandItem = $command->items()->offers()->get()->first();
            $commandItem->application_id = $oldCommandItem->application->id;
            $commandItem->save();


            $notification = $user->notifications->last();
            $application = $commandItem->application;

            RestoreApplicationJob::dispatch(['application'=>$application, 'notification'=>$notification]);

            $next = route('application.show', $commandItem->application_id);
            session()->forget('renew_command');
        }

        $command->save();
    }
 }

我的工作

class RestoreApplicationJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

protected $datas;

public $tries = 1;


public function __construct($datas)
{
    $this->datas = $datas;
}

public function handle()
{
    try{
        $application = $this->datas['application'];
        $notification = $this->datas['notification'];
        $application->activate();
        $tmp_data = $notification->data;
        $tmp_data['state'] = Opertation::SUCCESS;

        $notification->data = $tmp_data;
        $notification->save();
    }catch(\Exception $e)
    {
        Log::error($e->getMessage());
        Log::error($e->getTraceAsString());

        $tmp_data = $notification->data;
        $tmp_data['state'] = Opertation::FAILED;

        $notification->data = $tmp_data;
        $notification->save();
    }
}

}

我遇到此错误:

  

不允许对“关闭”进行序列化

我检查了很多次,但是什么也没找到

谢谢您的帮助,对不起我的英语不好:)!

1 个答案:

答案 0 :(得分:0)

我的问题太疯狂了...

这只是我在Job内将Opertation的类称为Operation。 抛出异常...

相关问题