📜  如何在 laravel 中获取年度图表 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:50.055000             🧑  作者: Mango

代码示例1
public function getYearlyVisits()
    {
        $monthlyVisitors = DB::table('shorteners')
            ->select([
                DB::raw('YEAR(created_at) as year'),
                DB::raw('count(total_visits as total_visits'),
            ])
            ->groupBy('year')
            ->get();
    }