public function getChartData()
    {
        // get all items between dates
        $rows = FeedbackContactUs::where('created_at', '>=', $this->inputDateFrom() . '%')
            ->where('created_at', '<=', $this->inputDateTo() . '  23:59:59')
            ->orderBy('created_at')
            ->get();

        // collection group by date
        $days = $rows->groupBy(function ($row) {
            return $row->created_at->format('l d F');
        })->all();

        // format and add to response
        $response = ['labels' => [], 'total' => 0];
        $line = [];
        foreach ($days as $date => $items) {
            $response['total'] += $items->count();
            $response['labels'][] = $date;

            $line[] = $items->count();
        }

        $response['datasets'][] = $this->getDataSet('Total', $line);

        return json_encode($response);
    }
public function getChartData()
    {
        // get all items between dates
        $rows = FeedbackContactUs::where('created_at', '>=', $this->inputDateFrom() . '%')
            ->where('created_at', '<=', $this->inputDateTo() . '  23:59:59')
            ->orderBy('created_at')
            ->get();

        // collection group by date
        $days = $rows->groupBy(function ($row) {
            return $row->created_at->format('l d F');
        })->all();

        // format and add to response
        $response = ['labels' => [], 'total' => 0];
        $line = [];
        foreach ($days as $date => $items) {
            $response['total'] += $items->count();
            $response['labels'][] = $date;

            $line[] = $items->count();
        }

        $response['datasets'][] = $this->getDataSet('Total', $line);

        return json_encode($response);
    }
public function getChartData ( ) { // get all items between dates $ rows = FeedbackContactUs :: where ( 'created_at' , '>=' , $ this -> inputDateFrom ( ) . '%' ) -> where ( 'created_at' , '<=' , $ this -> inputDateTo ( ) . '  23:59:59' ) -> orderBy ( 'created_at' ) -> get ( ) ; // collection group by date $ days = $ rows -> groupBy ( function ( $ row ) { return $ row -> created_at -> format ( 'l d F' ) ; } ) -> all ( ) ; // format and add to response $ response = [ 'labels' => [ ] , 'total' => 0 ] ; $ line = [ ] ; foreach ( $ days as $ date => $ items ) { $ response [ 'total' ] += $ items -> count ( ) ; $ response [ 'labels' ] [ ] = $ date ; $ line [ ] = $ items -> count ( ) ; } $ response [ 'datasets' ] [ ] = $ this -> getDataSet ( 'Total' , $ line ) ; return json_encode ( $ response ) ; }
Return the data formatted for chart
@return \Illuminate\Http\JsonResponse
Return the data formatted for chart