jeudi 4 mai 2017

Access Laravel Queued Job's payload data

How can I access the payload from within the Laravel job class?

I have tried:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

use App\PDF;

class ProcessConversion implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    protected $pdf;

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

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {

        $payload = $this->payload(); //undefined method
        $payload = $this->payload; //undefined property
        $payload = json_decode($this->getRawBody(), true); //undefined method

        ....

I got these from the Job class. But payload() and getRawBody() both return Call to undefined method.

Other methods from that class do work - for example, $this->release(1), so I'm not sure if $this does refer to the actual job class.

I am using the Redis queue driver, using Laravel 5.4.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire