Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Http/Requests/Admin/AdminFormRequest.php
10266 views
1
<?php
2
3
namespace Pterodactyl\Http\Requests\Admin;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
7
abstract class AdminFormRequest extends FormRequest
8
{
9
/**
10
* The rules to apply to the incoming form request.
11
*/
12
abstract public function rules(): array;
13
14
/**
15
* Determine if the user is an admin and has permission to access this
16
* form controller in the first place.
17
*/
18
public function authorize(): bool
19
{
20
if (is_null($this->user())) {
21
return false;
22
}
23
24
return (bool) $this->user()->root_admin;
25
}
26
27
/**
28
* Return only the fields that we are interested in from the request.
29
* This will include empty fields as a null value.
30
*/
31
public function normalize(?array $only = null): array
32
{
33
return $this->only($only ?? array_keys($this->rules()));
34
}
35
}
36
37