Merge pull request #222 from cachethq/incidents
Refactor how we get incidents
This commit is contained in:
@@ -22,11 +22,11 @@
|
||||
@include('partials.components')
|
||||
|
||||
{{-- @if(Setting::get('display_graphs'))
|
||||
@include('partials.graphs')
|
||||
@include('partials.graphs')
|
||||
@endif --}}
|
||||
|
||||
<h1>{{ trans('cachet.past_incidents') }}</h1>
|
||||
@foreach(range(0, 7) as $i => $v)
|
||||
@include('partials.incident', array('i', $i))
|
||||
@foreach($allIncidents as $incidents)
|
||||
@include('partials.incidents', $incidents)
|
||||
@endforeach
|
||||
@stop
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
<?php
|
||||
$incidentDate = Carbon\Carbon::now()->subDays($i);
|
||||
$incidents = Incident::whereBetween('created_at', [
|
||||
$incidentDate->format('Y-m-d') . ' 00:00:00',
|
||||
$incidentDate->format('Y-m-d') . ' 23:59:59',
|
||||
])->orderBy('created_at', 'desc')->get();
|
||||
?>
|
||||
<h4>{{ $incidentDate->format('jS F Y') }}</h4>
|
||||
<h4>{{ $date }}</h4>
|
||||
<div class='timeline'>
|
||||
<div class='content-wrapper'>
|
||||
@forelse($incidents as $incidentID => $incident)
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Component;
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Incident;
|
||||
use Setting;
|
||||
|
||||
class HomeController extends Controller
|
||||
@@ -19,10 +21,22 @@ class HomeController extends Controller
|
||||
{
|
||||
$components = Component::orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
$allIncidents = [];
|
||||
|
||||
foreach (range(0, 7) as $i) {
|
||||
$date = Carbon::now()->subDays($i);
|
||||
$incidents = Incident::whereBetween('created_at', [
|
||||
$date->format('Y-m-d').' 00:00:00',
|
||||
$date->format('Y-m-d').' 23:59:59',
|
||||
])->orderBy('created_at', 'desc')->get();
|
||||
$allIncidents[] = ['date' => $date->format('jS F Y'), 'incidents' => $incidents];
|
||||
}
|
||||
|
||||
return View::make('index', [
|
||||
'components' => $components,
|
||||
'pageTitle' => Setting::get('app_name'),
|
||||
'aboutApp' => Markdown::render(Setting::get('app_about')),
|
||||
'components' => $components,
|
||||
'allIncidents' => $allIncidents,
|
||||
'pageTitle' => Setting::get('app_name'),
|
||||
'aboutApp' => Markdown::render(Setting::get('app_about')),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user