Skip to content

PHP code snippet – How to get yearly chart in laravel?

    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();
    }
See also  PHP code snippet - How to remove last element from array?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.