Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Add support to get more information on the job class #2663

Open
iahmedsuhail opened this issue Jul 10, 2021 · 0 comments
Open

Add support to get more information on the job class #2663

iahmedsuhail opened this issue Jul 10, 2021 · 0 comments

Comments

@iahmedsuhail
Copy link

Currently, Job Middleware has the WithoutOverlapping amongst some other middlewares. It would be useful to have something that would allow accessing important information from the job, like the name of the job that was called, and the attributes of the class.

This would mean that I could use middleware to Log all important information about a job and send those logs to other places, maybe using the Log support.

I tried writing something on my own, but it looks like the $job attribute you get in the middleware isn't very useful and can only be used to pass it to the callback amongst some information (doesn't have much information that is accessible).

<?php

namespace App\Jobs\Middleware;

class Log
{
    /**
     * Logs the job and its details before and after processing a job.
     *
     * @param  mixed  $job
     * @param  callable  $next
     * @return mixed
     */
    public function handle($job, $next)
    {
        // $job isn't very useful here
    }
}

Some useful attributes that can be made available on the job can be the name of the class, the payload the job was called with, etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant