how to get yearly chart in laravel

Solutions on MaxInterview for how to get yearly chart in laravel by the best coders in the world

showing results for - "how to get yearly chart in laravel"
Isabella
11 Sep 2020
1    public function getYearlyVisits()
2    {
3        $monthlyVisitors = DB::table('shorteners')
4            ->select([
5                DB::raw('YEAR(created_at) as year'),
6                DB::raw('count(total_visits as total_visits'),
7            ])
8            ->groupBy('year')
9            ->get();
10    }
11