-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathStatusPageController.php
More file actions
60 lines (53 loc) · 1.75 KB
/
StatusPageController.php
File metadata and controls
60 lines (53 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Cachet\Http\Controllers\StatusPage;
use Cachet\Models\Component;
use Cachet\Models\ComponentGroup;
use Cachet\Models\Incident;
use Cachet\Models\Schedule;
use Cachet\Settings\AppSettings;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\View\View;
class StatusPageController
{
/**
* Create a new controller instance.
*/
public function __construct(protected AppSettings $appSettings)
{
//
}
/**
* Show the status page.
*/
public function index(): View
{
return view('cachet::status-page.index', [
'componentGroups' => ComponentGroup::query()
->with(['components' => fn ($query) => $query->enabled()->orderBy('order')->withCount('incidents')])
->visible(auth()->check())
->orderBy('order')
->when(auth()->check(), fn (Builder $query) => $query->users(), fn ($query) => $query->guests())
->get(),
'ungroupedComponents' => Component::query()
->enabled()
->whereNull('component_group_id')
->orderBy('order')
->withCount('incidents')
->get(),
'schedules' => Schedule::query()->with(['updates', 'components'])->orderBy('scheduled_at')->get(),
'display_graphs' => $this->appSettings->display_graphs,
]);
}
/**
* Show the details of a particular incident.
*/
public function show(Incident $incident): View
{
return view('cachet::status-page.incident', [
'incident' => $incident->loadMissing([
'components',
'updates' => fn ($query) => $query->orderByDesc('created_at'),
]),
]);
}
}