2014-11-16 22:26:08 +00:00
|
|
|
<?php
|
|
|
|
|
2015-01-01 16:18:24 +00:00
|
|
|
namespace CachetHQ\Cachet\Controllers;
|
2014-12-01 16:46:56 +00:00
|
|
|
|
2015-01-01 21:58:27 +00:00
|
|
|
use Carbon\Carbon;
|
2015-01-01 15:45:04 +00:00
|
|
|
use Component;
|
2015-01-01 19:44:15 +00:00
|
|
|
use GrahamCampbell\Markdown\Facades\Markdown;
|
2015-01-01 15:45:04 +00:00
|
|
|
use Illuminate\Routing\Controller;
|
2015-01-01 16:18:24 +00:00
|
|
|
use Illuminate\Support\Facades\View;
|
2015-01-01 21:58:27 +00:00
|
|
|
use Incident;
|
2015-01-01 15:45:04 +00:00
|
|
|
use Setting;
|
2014-12-01 16:46:56 +00:00
|
|
|
|
2015-01-01 15:45:04 +00:00
|
|
|
class HomeController extends Controller
|
|
|
|
{
|
2014-11-27 16:05:00 +00:00
|
|
|
/**
|
|
|
|
* Returns the rendered Blade templates.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-01 08:38:26 +00:00
|
|
|
* @return \Illuminate\View\View
|
2014-11-27 16:05:00 +00:00
|
|
|
*/
|
2014-12-20 21:20:17 +00:00
|
|
|
public function showIndex()
|
|
|
|
{
|
2015-01-01 13:37:47 +00:00
|
|
|
$components = Component::orderBy('order')->orderBy('created_at')->get();
|
|
|
|
|
2015-01-01 21:58:27 +00:00
|
|
|
$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];
|
|
|
|
}
|
|
|
|
|
2014-12-30 22:25:38 +00:00
|
|
|
return View::make('index', [
|
2015-01-01 22:09:36 +00:00
|
|
|
'components' => $components,
|
|
|
|
'allIncidents' => $allIncidents,
|
|
|
|
'pageTitle' => Setting::get('app_name'),
|
|
|
|
'aboutApp' => Markdown::render(Setting::get('app_about')),
|
2014-12-30 22:25:38 +00:00
|
|
|
]);
|
2014-11-27 16:05:00 +00:00
|
|
|
}
|
2014-11-27 22:08:28 +00:00
|
|
|
}
|