Laravel Eloquent get results grouped by days

前端 未结 14 596
一整个雨季
一整个雨季 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:26

    I had same problem, I'm currently using Laravel 5.3.

    I use DATE_FORMAT()

    ->groupBy(DB::raw("DATE_FORMAT(created_at, '%Y-%m-%d')"))
    

    Hopefully this will help you.

提交回复
热议问题