|
@@ 85-110 (lines=26) @@
|
| 82 |
|
* |
| 83 |
|
* @return \Illuminate\Support\Collection |
| 84 |
|
*/ |
| 85 |
|
protected function getIssues() |
| 86 |
|
{ |
| 87 |
|
$allIssues = Issue::whereBetween('created_at', [ |
| 88 |
|
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00', |
| 89 |
|
$this->startDate->format('Y-m-d').' 23:59:59', |
| 90 |
|
])->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) { |
| 91 |
|
return (new Date($issue->created_at)) |
| 92 |
|
->setTimezone($this->dateTimeZone)->toDateString(); |
| 93 |
|
}); |
| 94 |
|
|
| 95 |
|
// Add in days that have no issues |
| 96 |
|
foreach (range(0, 30) as $i) { |
| 97 |
|
$date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); |
| 98 |
|
|
| 99 |
|
if (!isset($allIssues[$date->toDateString()])) { |
| 100 |
|
$allIssues[$date->toDateString()] = []; |
| 101 |
|
} |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
// Sort the array so it takes into account the added days |
| 105 |
|
$allIssues = $allIssues->sortBy(function ($value, $key) { |
| 106 |
|
return strtotime($key); |
| 107 |
|
}, SORT_REGULAR, false); |
| 108 |
|
|
| 109 |
|
return $allIssues; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
/** |
| 113 |
|
* Fetches all of the subscribers over the last 30 days. |
|
@@ 117-142 (lines=26) @@
|
| 114 |
|
* |
| 115 |
|
* @return \Illuminate\Support\Collection |
| 116 |
|
*/ |
| 117 |
|
protected function getSubscribers() |
| 118 |
|
{ |
| 119 |
|
$allSubscribers = Subscriber::whereBetween('created_at', [ |
| 120 |
|
$this->startDate->copy()->subDays(30)->format('Y-m-d').' 00:00:00', |
| 121 |
|
$this->startDate->format('Y-m-d').' 23:59:59', |
| 122 |
|
])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $issue) { |
| 123 |
|
return (new Date($issue->created_at)) |
| 124 |
|
->setTimezone($this->dateTimeZone)->toDateString(); |
| 125 |
|
}); |
| 126 |
|
|
| 127 |
|
// Add in days that have no issues |
| 128 |
|
foreach (range(0, 30) as $i) { |
| 129 |
|
$date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i); |
| 130 |
|
|
| 131 |
|
if (!isset($allSubscribers[$date->toDateString()])) { |
| 132 |
|
$allSubscribers[$date->toDateString()] = []; |
| 133 |
|
} |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
// Sort the array so it takes into account the added days |
| 137 |
|
$allSubscribers = $allSubscribers->sortBy(function ($value, $key) { |
| 138 |
|
return strtotime($key); |
| 139 |
|
}, SORT_REGULAR, false); |
| 140 |
|
|
| 141 |
|
return $allSubscribers; |
| 142 |
|
} |
| 143 |
|
} |
| 144 |
|
|