Currently I have 4 different commands in "app/Console/Commands/", and I set them all up in app/Kernel.php, like this:
$schedule->command('command:start-imports-group-a')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
$schedule->command('command:start-imports-group-b')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
$schedule->command('command:start-imports-group-c')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
$schedule->command('command:start-imports-group-d')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
In my command php files (e.g. StartImportsGroupA.php, StartImportsGroupB.php, etc.) they are all calling the same function, but I'm simply setting a variable in each to change the "group" value. For example:
StartImportsGroupA.php
public function handle()
{
$group = 'a';
$this->startImports($group);
}
StartImportsGroupB.php
public function handle()
{
$group = 'b';
$this->startImports($group);
}
...and so on.
Is there an better way to do this? E.g. pass the "group" parameter to the command? That way I won't need 4 different command files to simply change that one $group variable's value.