Php Laravel Pull,groupBy自定义日期格式
使用Pull时无法格式化创建的\uPhp Laravel Pull,groupBy自定义日期格式,php,laravel,date-formatting,pluck,Php,Laravel,Date Formatting,Pluck,使用Pull时无法格式化创建的\u VisitorsStatistic::where('landing_page_id', $this->landing_page->id) ->select('created_at', DB::raw('count(*) as visitors')) ->whereMonth('created_at', '>=', $this->start_month) ->wher
VisitorsStatistic::where('landing_page_id', $this->landing_page->id)
->select('created_at', DB::raw('count(*) as visitors'))
->whereMonth('created_at', '>=', $this->start_month)
->whereMonth('created_at', '<=', $this->end_month)
->orderBy('created_at')
->groupBy('created_at')
->pluck('visitors','created_at')
->all();
有没有一种方法可以在使用Pull时格式化创建的日期?试一试:
VisitorsStatistic::where('landing\u page\u id',$this->landing\u page->id)
->选择(\DB::raw(“日期格式(创建时间,%Y-%m-%d))作为创建时间”),\DB::raw(“计数(*)作为访问者”)
->whereMonth('created_at','>=',$this->start_month)
->whereMonth('created_at','nice you让我觉得自己很愚蠢,工作太多了,没有想到更简单的解决方案。不,你不愚蠢。几个月前,我用不同的MySQL函数看了完全一样的东西。我们都是学生,总是在学习新东西。祝你好运
//->groupBy(function($val) {
// return Carbon::parse($val->created_at)->format('d/m');
//})