Fixes #934 - Scheduled items now drop into the right days

This commit is contained in:
James Brooks
2015-09-04 08:18:10 +01:00
parent 860457bfae
commit 0851427f2d
4 changed files with 37 additions and 4 deletions

View File

@@ -65,7 +65,13 @@ class HomeController extends AbstractController
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
$startDate->format('Y-m-d').' 23:59:59',
])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {
])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {
// If it's scheduled, get the scheduled at date.
if ($incident->is_scheduled) {
return (new Date($incident->scheduled_at))
->setTimezone($dateTimeZone)->toDateString();
}
return (new Date($incident->created_at))
->setTimezone($dateTimeZone)->toDateString();
});