I have already tried resolve of this and this, finally, they do not resolve my problem.
I added job to my queue like this
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();
}
}
And my Job
class RestoreApplicationJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $datas;
public $tries = 1;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($datas)
{
$this->datas = $datas;
}
/**
* Execute the job.
*
* @return void
*/
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();
}
}
}
I have this error :
Serialization of 'Closure' is not allowed
I checked many times where it stucks but, don't find anything
Thank you for your help and sorry for my so bad english :) !
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire