I need to make a query from my table where I track page views and group the results by the time of the day, more specifically group them by 2 hour interval. Now I am getting results by each hour:
$visitorTraffic = DB::table('views')
->select(DB::raw('MONTH(created_at) as m, YEAR(created_at) as y, HOUR(created_at) as h, count(*)'))
->groupBy(DB::raw('HOUR(created_at)'))
->get();