Cachet/app/view-composers.php

25 lines
678 B
PHP

<?php
View::composer('index', function($view) {
$date = date('Y-m-d');
$incidents = Incident::whereRaw('DATE(created_at) = "' . $date . '"')
->groupBy('status')
->orderBy('status', 'desc');
$incidentCount = $incidents->count();
if ($incidentCount <= 1 || ($incidentCount > 1 && (int) $incidents->first()->status === 4)) {
$status = 'success';
$message = Lang::get('cachet.service.good');
} else {
$status = 'danger';
$message = Lang::get('cachet.service.bad');
}
$view->with([
'systemStatus' => $status,
'systemMessage' => $message
]);
});