protected function getSubscribers()
    {
        $allSubscribers = Subscriber::whereBetween('created_at', [
            $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
            $this->startDate->format('Y-m-d').' 23:59:59',
        ])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) {
            return (new Date($incident->created_at))
                ->setTimezone($this->dateTimeZone)->toDateString();
        });

        // Add in days that have no incidents
        foreach (range(0, 30) as $i) {
            $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);

            if (!isset($allSubscribers[$date->toDateString()])) {
                $allSubscribers[$date->toDateString()] = [];
            }
        }

        // Sort the array so it takes into account the added days
        $allSubscribers = $allSubscribers->sortBy(function ($value, $key) {
            return strtotime($key);
        }, SORT_REGULAR, false);

        return $allSubscribers;
    }
protected function getSubscribers()
    {
        $allSubscribers = Subscriber::whereBetween('created_at', [
            $this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00',
            $this->startDate->format('Y-m-d').' 23:59:59',
        ])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $incident) {
            return (new Date($incident->created_at))
                ->setTimezone($this->dateTimeZone)->toDateString();
        });

        // Add in days that have no incidents
        foreach (range(0, 30) as $i) {
            $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);

            if (!isset($allSubscribers[$date->toDateString()])) {
                $allSubscribers[$date->toDateString()] = [];
            }
        }

        // Sort the array so it takes into account the added days
        $allSubscribers = $allSubscribers->sortBy(function ($value, $key) {
            return strtotime($key);
        }, SORT_REGULAR, false);

        return $allSubscribers;
    }
protected function getSubscribers ( ) { $ allSubscribers = Subscriber :: whereBetween ( 'created_at' , [ $ this -> startDate -> copy ( ) -> subDays ( 30 ) -> format ( 'Y-m-d' ) . ' 00:00:00' , $ this -> startDate -> format ( 'Y-m-d' ) . ' 23:59:59' , ] ) -> orderBy ( 'created_at' , 'desc' ) -> get ( ) -> groupBy ( function ( Subscriber $ incident ) { return ( new Date ( $ incident -> created_at ) ) -> setTimezone ( $ this -> dateTimeZone ) -> toDateString ( ) ; } ) ; // Add in days that have no incidents foreach ( range ( 0 , 30 ) as $ i ) { $ date = ( new Date ( $ this -> startDate ) ) -> setTimezone ( $ this -> dateTimeZone ) -> subDays ( $ i ) ; if ( ! isset ( $ allSubscribers [ $ date -> toDateString ( ) ] ) ) { $ allSubscribers [ $ date -> toDateString ( ) ] = [ ] ; } } // Sort the array so it takes into account the added days $ allSubscribers = $ allSubscribers -> sortBy ( function ( $ value , $ key ) { return strtotime ( $ key ) ; } , SORT_REGULAR , false ) ; return $ allSubscribers ; }
Fetches all of the subscribers over the last 30 days.

@return \Illuminate\Support\Collection
Fetches all of the subscribers over the last 30 days .