public function authReports() { $reportData = ['factor', 'integration', 'reason', 'result']; $colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink']; $totalLogs = DuoLog::select('id')->count(); foreach ($reportData as $report) { $res = \DB::select("SELECT DISTINCT {$report}, count(*) as count FROM duo_logs GROUP BY {$report}"); foreach ($res as $graph) { $graphData[$report][$graph->{$report}]['count'] = number_format($graph->count / $totalLogs, 3) * 100; $graphData[$report][$graph->{$report}]['backgroundColor'] = RandomColor::one(['hue' => $colors[array_rand($colors, 1)]]); $graphData[$report][$graph->{$report}]['hoverBackgroundColor'] = "#00C0EF"; } } return view('duo.authlogs.reports', compact('graphData')); }