File: D:/HostingSpaces/MdnDirecteur/hours.komma.cloud/app/Console/Commands/autoGenerateProjects.php
<?php
namespace App\Console\Commands;
use App\Komma\Commands\CommandsService;
use App\Komma\Projects\Project;
use Illuminate\Console\Command;
use Carbon\Carbon;
class autoGenerateProjects extends Command
{
protected $commandsService;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'auto-generate:projects';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Auto generate projects based on create every x month value';
public function __construct(CommandsService $commandsService)
{
parent::__construct();
$this->commandsService = $commandsService;
}
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$projects = Project::whereNotNull('create_every_x_months')->with('Subprojects')->where('archived', '0')->get();
$this->info('Found '.count($projects).' project(s) that might need to auto-generate');
$this->commandsService->autoGenerateProjects($this, $projects);
}
}