Passing Custom Command arguments to Job on Redis Queue
New to Lumen and wanting to use it for a backend app using Redis.
I have the following Custom Command -
class Add extends Command { protected $signature = 'region:add {region}'; protected $description = 'Add region node as required'; protected $region;
public function __construct()
{
parent::__construct();
}
public function handle()
{
try{
$this->region = $this->argument('region');
customLogging::Console('arg value = '.$this->region);
if($this->region){
Queue::pushOn('region', new Add($this->region));
customLogging::Log('region','info', 'Region Added to queue successfully - '.$this->region);
customLogging::Console('Region Added to queue successfully - '.$this->region);
}else{
customLogging::Console('Region Add New - no region given.');
}
}catch(Exception $e){
customLogging::Console('Region Add New - '.$e);
customLogging::Log('region','info', 'Add Region - '.$e);
}
}
}
And I am trying to pass the $region variable to a Job. the commands grabs the argument fine -
class Add extends Job implements ShouldQueue { use InteractsWithQueue, SerializesModels;
protected $region;
public function __construct($region)
{
if(isset($region)){
$this->region = $region;
}else{
Log::info('Region add - missing region');
}
}
public function handle()
{
try{
//
$this->CreateServer();
customLogging::Console('Job:arg value = '.$this->region);
customLogging::Log('region','info', 'New region server requested - '.$this->region);
}catch(Exception $e){
customLogging::Console('Region Add Job - '.$e);
customLogging::Log('region','info', 'Add Job - '.$e);
}
}
function CreateServer(){}
}
But i keep getting the error and I am stuck -
lumen.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getArgument() on null in /var/www/html/core-director/vendor/illuminate/console/Command.php:256
Would appreciate any advice, hints.
Please or to participate in this conversation.