Search code examples
phplaravellaravel-7

Set laravel job's timeout based on some config


To set Laravel job's $timeout value we can use this code

public $timeout = 120;

Is there a way to set this value dynamically (via a method)? something like this

public function timeout(): int
{
    return config('general.some_config');
}

The above code does not seem to have any effect on the job's timeout value.


Solution

  • You can assign it by constructor in like this

    public function __construct()
    {
        $this->timeout = config('general.some_config');
    }