/** * Return the statistics of visitors * * @param string $scope * * @return array */ public static function statistics($scope = 'all') { //Return the list of visitors based on scope if ($scope == 'all') { $list = Visitor::all(); } else { try { $list = Visitor::$scope()->get(); } catch (Exception $e) { $list = Visitor::all(); flash()->error('Caught exception: ' . $e->getMessage()); } } //Return the counts $all_count = Visitor::all()->count(); $today_count = Visitor::today()->get()->count(); $previous_count = Visitor::previousSunday()->get()->count(); return ['all_count' => $all_count, 'today_count' => $today_count, 'previous_count' => $previous_count, 'list' => $list]; }