forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActivityEventRequest.php
More file actions
50 lines (44 loc) · 1.35 KB
/
ActivityEventRequest.php
File metadata and controls
50 lines (44 loc) · 1.35 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
<?php
namespace Pterodactyl\Http\Requests\Api\Remote;
use Illuminate\Support\Collection;
use Illuminate\Foundation\Http\FormRequest;
class ActivityEventRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'data' => ['required', 'array'],
'data.*' => ['array'],
'data.*.user' => ['sometimes', 'nullable', 'uuid'],
'data.*.server' => ['required', 'uuid'],
'data.*.event' => ['required', 'string'],
'data.*.metadata' => ['present', 'nullable', 'array'],
'data.*.ip' => ['sometimes', 'nullable', 'ip'],
'data.*.timestamp' => ['required', 'string'],
];
}
/**
* Returns all the unique server UUIDs that were received in this request.
*/
public function servers(): array
{
return Collection::make($this->input('data'))->pluck('server')->unique()->toArray();
}
/**
* Returns all the unique user UUIDs that were submitted in this request.
*/
public function users(): array
{
return Collection::make($this->input('data'))
->filter(function ($value) {
return !empty($value['user']);
})
->pluck('user')
->unique()
->toArray();
}
}