Cachet/app/composers.php

34 lines
1002 B
PHP
Raw Normal View History

2014-11-16 23:59:14 +00:00
<?php
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
2015-01-01 20:37:58 +00:00
use Illuminate\Support\Facades\View;
2014-12-20 21:20:17 +00:00
View::composer('index', function ($view) {
2014-12-01 08:42:11 +00:00
$date = date('Y-m-d');
2014-11-17 00:09:35 +00:00
2014-12-31 15:56:08 +00:00
$components = Component::notStatus(1);
2014-11-24 17:02:03 +00:00
2014-12-31 15:56:08 +00:00
if (Component::all()->count() === 0 || $components->count() === 0) {
// If all our components are ok, do we have any non-fixed incidents?
$incidents = Incident::orderBy('created_at', 'desc')->get();
$incidentCount = $incidents->count();
if ($incidentCount === 0 || ($incidentCount >= 1 && (int) $incidents->first()->status === 4)) {
$status = 'success';
$message = trans('cachet.service.good');
2014-12-31 15:56:08 +00:00
} else {
$status = 'danger';
$message = trans('cachet.service.bad');
2014-12-31 15:56:08 +00:00
}
2014-12-01 08:42:11 +00:00
} else {
$status = 'danger';
$message = trans('cachet.service.bad');
2014-12-01 08:42:11 +00:00
}
2014-11-16 23:59:14 +00:00
2014-12-01 08:42:11 +00:00
$view->with([
'systemStatus' => $status,
2014-12-20 21:20:17 +00:00
'systemMessage' => $message,
2014-12-01 08:42:11 +00:00
]);
});