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