app/Http/Controllers/Admin/Charts/WeeklyHiredProductsChartController.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--) {
            $products[] = HiredProduct::whereDate('created_at', today()
                ->subDays($days_backwards))
                ->count();
        }
        $this->chart->dataset('Products', 'bar', $products)
            ->color('rgba(205, 32, 31, 1)')
            ->backgroundColor('rgba(205, 32, 31, 0.4)');
    }
public function data ( ) { for ( $ days_backwards = 30 ; $ days_backwards >= 0 ; $ days_backwards -- ) { $ products [ ] = HiredProduct :: whereDate ( 'created_at' , today ( ) -> subDays ( $ days_backwards ) ) -> count ( ) ; } $ this -> chart -> dataset ( 'Products' , 'bar' , $ products ) -> color ( 'rgba(205, 32, 31, 1)' ) -> backgroundColor ( 'rgba(205, 32, 31, 0.4)' ) ; }
Respond to AJAX calls with all the chart data points.
Respond to AJAX calls with all the chart data points .
// Could also be an array_push if using an array rather than a collection.