2015-01-14 10:00:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace CachetHQ\Cachet\Composers;
|
|
|
|
|
|
|
|
use CachetHQ\Cachet\Models\Component;
|
|
|
|
use CachetHQ\Cachet\Models\Incident;
|
2015-01-28 00:51:28 -06:00
|
|
|
use Illuminate\View\View;
|
2015-01-14 10:00:30 +00:00
|
|
|
|
|
|
|
class IndexComposer
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Index page view composer.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\View\View $view
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-01-28 00:51:28 -06:00
|
|
|
public function compose(View $view)
|
2015-01-14 10:00:30 +00:00
|
|
|
{
|
2015-01-14 10:11:47 +00:00
|
|
|
// Default data
|
|
|
|
$withData = [
|
|
|
|
'systemStatus' => 'danger',
|
|
|
|
'systemMessage' => trans('cachet.service.bad'),
|
|
|
|
];
|
|
|
|
|
2015-01-14 16:19:11 +00:00
|
|
|
if (Component::notStatus(1)->count() === 0) {
|
2015-01-14 10:00:30 +00:00
|
|
|
// 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)) {
|
2015-01-14 10:11:47 +00:00
|
|
|
$withData = [
|
|
|
|
'systemStatus' => 'success',
|
|
|
|
'systemMessage' => trans('cachet.service.good'),
|
|
|
|
];
|
2015-01-14 10:00:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-14 10:11:47 +00:00
|
|
|
$view->with($withData);
|
2015-01-14 10:00:30 +00:00
|
|
|
}
|
|
|
|
}
|