Laravel Eloquent get results grouped by days

前端 未结 14 652
一整个雨季
一整个雨季 2020-12-02 06:44

I currently have a table of page_views that records one row for each time a visitor accesses a page, recording the user\'s ip/id and the id of the page itself. I should add

14条回答
  •  悲&欢浪女
    2020-12-02 07:18

    Warning: untested code.

    $dailyData = DB::table('page_views')
        ->select('created_at', DB::raw('count(*) as views'))
        ->groupBy('created_at')
        ->get();
    

提交回复
热议问题