app/Http/Controllers/Statistics.php
/**
     * Processes item counts using the date.
     *
     * @param Collection $collection
     * @param string     $attribute
     * @param Carbon     $from
     * @param Carbon     $to
     *
     * @return array
     */
Processes item counts using the date.

@return array
Processes item counts using the date . @return array
public static function processCollectionCountByDate(Collection $collection, string $attribute, Carbon $from, Carbon $to): array
    {
        $start = clone $from;
        $data = [];
        while ($start->lessThanOrEqualTo($to)) {
            $key = $start->format('Y-m-d');
            $data[$key] = $collection->filter(function ($model) use ($start, $attribute) {
                return $model->{$attribute}->greaterThanOrEqualTo($start->startOfDay()) &&
                    $model->{$attribute}->lessThanOrEqualTo($start->endOfDay());
            })->count();
            $start->addDay();
        }
        return $data;
    }
public static function processCollectionCountByDate ( Collection $ collection , string $ attribute , Carbon $ from , Carbon $ to ) : array { $ start = clone $ from ; $ data = [ ] ; while ( $ start -> lessThanOrEqualTo ( $ to ) ) { $ key = $ start -> format ( 'Y-m-d' ) ; $ data [ $ key ] = $ collection -> filter ( function ( $ model ) use ( $ start , $ attribute ) { return $ model -> { $ attribute } -> greaterThanOrEqualTo ( $ start -> startOfDay ( ) ) && $ model -> { $ attribute } -> lessThanOrEqualTo ( $ start -> endOfDay ( ) ) ; } ) -> count ( ) ; $ start -> addDay ( ) ; } return $ data ; }
Processes item counts using the date.
Processes item counts using the date .
# get the data