visit($request->user()); } /** * 오늘 방문자 수 */ public function todayCount(): int { return $this->whereDate('created_at', now()->today())->distinct()->count('ip'); } /** * 어제 방문자 수 */ public function yesterdayCount(): int { return $this->whereDate('created_at', now()->yesterday())->distinct()->count('ip'); } /** * 누적 방문자 수 */ public function totalCount(): int { $sql = " SELECT SUM(`CNT`) AS `total` FROM ( SELECT COUNT(DISTINCT `ip`) AS CNT FROM `visits` WHERE 1 GROUP BY DATE_FORMAT(created_at, '%Y%m%d') ) D; "; return DB::selectOne($sql)->total; } }