frapto
1 week ago
165
5
Laravel

Is there a way to get the uuid of a job?

Posted 1 week ago by frapto

Hello, I am using the database queue driver and i can see the uuid in the payload. Is there a way i can get the uuid without querying the table? (prior to insertion) This is my current implementation

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;

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

    protected $userData;
    protected $filename;
    public $timeout = 1200;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($userData, $filename)
    {
        //init
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //do something here
    }
}

I tried extending the Job abstract class, but it throws a class cast exception

Please sign in or create an account to participate in this conversation.