1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cortex\Statistics\Http\Controllers\Adminarea; |
6
|
|
|
|
7
|
|
|
use Cortex\Statistics\DataTables\Adminarea\PathsDataTable; |
8
|
|
|
use Cortex\Statistics\DataTables\Adminarea\AgentsDataTable; |
9
|
|
|
use Cortex\Statistics\DataTables\Adminarea\GeoipsDataTable; |
10
|
|
|
use Cortex\Statistics\DataTables\Adminarea\RoutesDataTable; |
11
|
|
|
use Cortex\Foundation\Http\Controllers\AuthorizedController; |
12
|
|
|
use Cortex\Statistics\DataTables\Adminarea\DevicesDataTable; |
13
|
|
|
use Cortex\Statistics\DataTables\Adminarea\RequestsDataTable; |
14
|
|
|
use Cortex\Statistics\DataTables\Adminarea\PlatformsDataTable; |
15
|
|
|
|
16
|
|
|
class StatisticsController extends AuthorizedController |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* {@inheritdoc} |
20
|
|
|
*/ |
21
|
|
|
protected $resource = 'statistics'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
protected $resourceMethodsWithoutModels = [ |
27
|
|
|
'agents', |
28
|
|
|
'geoips', |
29
|
|
|
'devices', |
30
|
|
|
'paths', |
31
|
|
|
'platforms', |
32
|
|
|
'requests', |
33
|
|
|
'routes', |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public function authorizeResource($model, $parameter = null, array $options = [], $request = null): void |
40
|
|
|
{ |
41
|
|
|
$middleware = []; |
42
|
|
|
|
43
|
|
|
foreach ($this->mapResourceAbilities() as $method => $ability) { |
44
|
|
|
$middleware['can:list-statistics'][] = $method; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
foreach ($middleware as $middlewareName => $methods) { |
48
|
|
|
$this->middleware($middlewareName, $options)->only($methods); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Show statistics index. |
54
|
|
|
* |
55
|
|
|
* @return \Illuminate\View\View |
56
|
|
|
*/ |
57
|
|
|
public function index() |
58
|
|
|
{ |
59
|
|
|
return view('cortex/foundation::adminarea.pages.index'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* List all agents. |
64
|
|
|
* |
65
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\AgentsDataTable $agentsDataTable |
66
|
|
|
* |
67
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
68
|
|
|
*/ |
69
|
|
|
public function agents(AgentsDataTable $agentsDataTable) |
70
|
|
|
{ |
71
|
|
|
return $agentsDataTable->with([ |
72
|
|
|
'id' => 'adminarea-statistics-agents-table', |
73
|
|
|
'phrase' => trans('cortex/statistics::common.agents'), |
74
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* List all geoips. |
79
|
|
|
* |
80
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\GeoipsDataTable $geoipsDataTable |
81
|
|
|
* |
82
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
83
|
|
|
*/ |
84
|
|
|
public function geoips(GeoipsDataTable $geoipsDataTable) |
85
|
|
|
{ |
86
|
|
|
return $geoipsDataTable->with([ |
87
|
|
|
'id' => 'adminarea-statistics-geoips-table', |
88
|
|
|
'phrase' => trans('cortex/statistics::common.geoips'), |
89
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* List all devices. |
94
|
|
|
* |
95
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\DevicesDataTable $devicesDataTable |
96
|
|
|
* |
97
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
98
|
|
|
*/ |
99
|
|
|
public function devices(DevicesDataTable $devicesDataTable) |
100
|
|
|
{ |
101
|
|
|
return $devicesDataTable->with([ |
102
|
|
|
'id' => 'adminarea-statistics-devices-table', |
103
|
|
|
'phrase' => trans('cortex/statistics::common.devices'), |
104
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* List all paths. |
109
|
|
|
* |
110
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\PathsDataTable $pathsDataTable |
111
|
|
|
* |
112
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
113
|
|
|
*/ |
114
|
|
|
public function paths(PathsDataTable $pathsDataTable) |
115
|
|
|
{ |
116
|
|
|
return $pathsDataTable->with([ |
117
|
|
|
'id' => 'adminarea-statistics-paths-table', |
118
|
|
|
'phrase' => trans('cortex/statistics::common.paths'), |
119
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* List all platforms. |
124
|
|
|
* |
125
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\PlatformsDataTable $platformsDataTable |
126
|
|
|
* |
127
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
128
|
|
|
*/ |
129
|
|
|
public function platforms(PlatformsDataTable $platformsDataTable) |
130
|
|
|
{ |
131
|
|
|
return $platformsDataTable->with([ |
132
|
|
|
'id' => 'adminarea-statistics-platforms-table', |
133
|
|
|
'phrase' => trans('cortex/statistics::common.platforms'), |
134
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* List all requests. |
139
|
|
|
* |
140
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\RequestsDataTable $requestsDataTable |
141
|
|
|
* |
142
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
143
|
|
|
*/ |
144
|
|
|
public function requests(RequestsDataTable $requestsDataTable) |
145
|
|
|
{ |
146
|
|
|
return $requestsDataTable->with([ |
147
|
|
|
'id' => 'adminarea-statistics-requests-table', |
148
|
|
|
'phrase' => trans('cortex/statistics::common.requests'), |
149
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* List all routes. |
154
|
|
|
* |
155
|
|
|
* @param \Cortex\Statistics\DataTables\Adminarea\RoutesDataTable $routesDataTable |
156
|
|
|
* |
157
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\View\View |
158
|
|
|
*/ |
159
|
|
|
public function routes(RoutesDataTable $routesDataTable) |
160
|
|
|
{ |
161
|
|
|
return $routesDataTable->with([ |
162
|
|
|
'id' => 'adminarea-statistics-routes-table', |
163
|
|
|
'phrase' => trans('cortex/statistics::common.routes'), |
164
|
|
|
])->render('cortex/foundation::adminarea.pages.datatable'); |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|