/** * @return null */ private function getMinTime() { // Get the last Duo log based on Unix Timestamp $lastLog = Log::orderBy('timestamp', 'desc')->first(); // If there are no logs, there is no $mintime to set // Otherwise set it to the latest timestamp in our database if (is_null($lastLog['timestamp'])) { $mintime = NULL; } else { $mintime = $lastLog['timestamp']->timestamp + 1; } \Log::debug('Calculated Mintime: ', ['mintime' => $mintime, 'lastLog' => $lastLog]); return $mintime; }
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')); }