app/Http/Controllers/Admin/Charts/WeeklyUsersChartController.php
/**
     * Respond to AJAX calls with all the chart data points.
     *
     * @return json
     */
Respond to AJAX calls with all the chart data points.
@return json
Respond to AJAX calls with all the chart data points . @return json
public function data()
    {
         for ($days_backwards = 30; $days_backwards >= 0; $days_backwards--) {
            $users[] = User::whereDate('created_at', today()
                ->subDays($days_backwards))
                ->count();
        }
        $this->chart->dataset('Users', 'line', $users)
            ->color('rgb(77, 189, 116)')
            ->backgroundColor('rgba(77, 189, 116, 0.4)');
    }
public function data ( ) { for ( $ days_backwards = 30 ; $ days_backwards >= 0 ; $ days_backwards -- ) { $ users [ ] = User :: whereDate ( 'created_at' , today ( ) -> subDays ( $ days_backwards ) ) -> count ( ) ; } $ this -> chart -> dataset ( 'Users' , 'line' , $ users ) -> color ( 'rgb(77, 189, 116)' ) -> backgroundColor ( 'rgba(77, 189, 116, 0.4)' ) ; }
Respond to AJAX calls with all the chart data points.
Respond to AJAX calls with all the chart data points .
// $users_created_today = \App\Models\User::whereDate('created_at', today())->count(); // $this->chart->dataset('Users Created', 'bar', [ //             $users_created_today, //         ]) //     ->color('rgba(205, 32, 31, 1)') //     ->backgroundColor('rgba(205, 32, 31, 0.4)'); // Could also be an array_push if using an array rather than a collection. // $articles[] = Article::whereDate('created_at', today() //     ->subDays($days_backwards)) //     ->count(); // $categories[] = Category::whereDate('created_at', today() //     ->subDays($days_backwards)) //     ->count(); // $tags[] = Tag::whereDate('created_at', today() //     ->subDays($days_backwards)) //     ->count();