$collections = Collection::selectRaw("DATE(created_at) as collection_date, sum(gross_amount) as amount")
->groupBy('collection_date')
->paginate(10);
当我这样做时,它显示collection_date在表中不存在,所以我想知道我如何通过雄辩地使用date((来创建组?
感谢
基于Laravel文档,分页不能正确使用groupBy子句。https://laravel.com/docs/7.x/pagination#paginating-查询生成器结果
目前,Laravel无法有效执行使用groupBy语句的分页操作。如果需要使用带有分页结果集的groupBy,建议查询数据库并手动创建分页器。