I'm using PHP (Laravel) to iterate over the survey_answers table and build datasets which I can show in a graph. I'm just wondering if this is the way to go.ChartFactory.phppublic static function buildFromSurvey($survey){    $chart = new Chart($survey->name);    foreach($survey->answers as $answer) {        if($chart->hasDataset($answer->user_id)) {            $dataset = $chart->getDataset($answer->user_id);        } else {            $dataset = new Dataset();            $dataset->setTitle($answer->user->name);            $dataset->setColor(config('assessment.chart_colors_survey')[0]);            $dataset->setOwner($answer->user);            $chart->addDataSet($dataset);        }        // Create the category if not exists in this dataset        if ($dataset->hasDataItem($answer->question->category->name)) {            $category = $dataset->getDataItem($answer->question->category->name);            $category->addScore($answer->score);        } else {            $category = new Category();            $category->setName($answer->question->category->name);            $category->addScore($answer->score);            $dataset->addDataItem($category);            $chart->addLabel($answer->question->category->name);        }    }    return $chart;}
Plotting a graph of survey answers in Laravel
php;object oriented;laravel;data visualization