<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Helpers\MasterFunctionsHelper;
use App\Models\Project;

class CalculateSCurve extends Command
{
  protected $signature = 'calculate:scurve {project_id}';
  
  protected $description = 'Calculate S Curve';
  
  public function handle()
  {
    $project_id = $this->argument('project_id');
    $project = Project::find($project_id);

    $project->calculation_status = true;
    $project->save();

    $data = MasterFunctionsHelper::CalculateSCurve($project_id);

    $project->scurve = json_encode($data);
    $project->calculation_status = true;
    $project->save();
  }
}