Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -8,18 +8,14 @@ abstract class AdminFormRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* The rules to apply to the incoming form request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function rules();
|
||||
abstract public function rules(): array;
|
||||
|
||||
/**
|
||||
* Determine if the user is an admin and has permission to access this
|
||||
* form controller in the first place.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (is_null($this->user())) {
|
||||
return false;
|
||||
|
@ -31,10 +27,8 @@ abstract class AdminFormRequest extends FormRequest
|
|||
/**
|
||||
* Return only the fields that we are interested in from the request.
|
||||
* This will include empty fields as a null value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function normalize(array $only = null)
|
||||
public function normalize(array $only = null): array
|
||||
{
|
||||
return $this->only($only ?? array_keys($this->rules()));
|
||||
}
|
||||
|
|
|
@ -9,12 +9,10 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
class StoreApplicationApiKeyRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$modelRules = ApiKey::getRules();
|
||||
|
||||
|
@ -23,10 +21,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest
|
|||
})->merge(['memo' => $modelRules['memo']])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'memo' => 'Description',
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin;
|
||||
|
||||
class BaseFormRequest extends AdminFormRequest
|
||||
{
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'company' => 'required|between:1,256',
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
namespace Pterodactyl\Http\Requests\Admin;
|
||||
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
|
||||
class DatabaseHostFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
if ($this->method() !== 'POST') {
|
||||
return DatabaseHost::getRulesForUpdate($this->route()->parameter('host'));
|
||||
|
@ -20,10 +18,8 @@ class DatabaseHostFormRequest extends AdminFormRequest
|
|||
|
||||
/**
|
||||
* Modify submitted data before it is passed off to the validator.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function getValidatorInstance()
|
||||
protected function getValidatorInstance(): Validator
|
||||
{
|
||||
if (!$this->filled('node_id')) {
|
||||
$this->merge(['node_id' => null]);
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class EggFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:191',
|
||||
|
@ -39,9 +29,6 @@ class EggFormRequest extends AdminFormRequest
|
|||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
*/
|
||||
public function withValidator($validator)
|
||||
{
|
||||
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
||||
|
@ -49,7 +36,7 @@ class EggFormRequest extends AdminFormRequest
|
|||
});
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
public function validated($key = null, $default = null): array
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class EggImportFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'import_file' => 'bail|required|file|max:1000|mimetypes:application/json,text/plain',
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
|
@ -14,11 +7,9 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
class EggScriptFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Return the rules to be used when validating the sent data in the request.
|
||||
*
|
||||
* @return array
|
||||
* Return the rules to be used when validating the data sent in the request.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'script_install' => 'sometimes|nullable|string',
|
||||
|
|
|
@ -9,10 +9,8 @@ class EggVariableFormRequest extends AdminFormRequest
|
|||
{
|
||||
/**
|
||||
* Define rules for validation of this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:1|max:191',
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin;
|
||||
|
||||
|
@ -14,11 +7,9 @@ use Pterodactyl\Models\Location;
|
|||
class LocationFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Setup the validation rules to use for these requests.
|
||||
*
|
||||
* @return array
|
||||
* Set up the validation rules to use for these requests.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
if ($this->method() === 'PATCH') {
|
||||
return Location::getRulesForUpdate($this->route()->parameter('location')->id);
|
||||
|
|
|
@ -7,11 +7,9 @@ use Pterodactyl\Models\Mount;
|
|||
class MountFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Setup the validation rules to use for these requests.
|
||||
*
|
||||
* @return array
|
||||
* Set up the validation rules to use for these requests.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
if ($this->method() === 'PATCH') {
|
||||
return Mount::getRulesForUpdate($this->route()->parameter('mount')->id);
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Nest;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class StoreNestFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:1|max:191',
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Node;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class AllocationAliasFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'alias' => 'present|nullable|string',
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Node;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class AllocationFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'allocation_ip' => 'required|string',
|
||||
|
|
|
@ -11,7 +11,7 @@ class NodeFormRequest extends AdminFormRequest
|
|||
/**
|
||||
* Get rules to apply to data in this request.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
if ($this->method() === 'PATCH') {
|
||||
return Node::getRulesForUpdate($this->route()->parameter('node'));
|
||||
|
|
|
@ -4,15 +4,14 @@ namespace Pterodactyl\Http\Requests\Admin;
|
|||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class ServerFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Rules to be applied to this request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = Server::getRules();
|
||||
$rules['description'][] = 'nullable';
|
||||
|
@ -23,14 +22,12 @@ class ServerFormRequest extends AdminFormRequest
|
|||
|
||||
/**
|
||||
* Run validation after the rules above have been applied.
|
||||
*
|
||||
* @param \Illuminate\Validation\Validator $validator
|
||||
*/
|
||||
public function withValidator($validator)
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(function ($validator) {
|
||||
$validator->sometimes('node_id', 'required|numeric|bail|exists:nodes,id', function ($input) {
|
||||
return !($input->auto_deploy);
|
||||
return !$input->auto_deploy;
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation_id', [
|
||||
|
@ -42,7 +39,7 @@ class ServerFormRequest extends AdminFormRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return !($input->auto_deploy);
|
||||
return !$input->auto_deploy;
|
||||
});
|
||||
|
||||
$validator->sometimes('allocation_additional.*', [
|
||||
|
@ -54,7 +51,7 @@ class ServerFormRequest extends AdminFormRequest
|
|||
$query->whereNull('server_id');
|
||||
}),
|
||||
], function ($input) {
|
||||
return !($input->auto_deploy);
|
||||
return !$input->auto_deploy;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,11 +7,9 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
class AdvancedSettingsFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Return all of the rules to apply to this request's data.
|
||||
*
|
||||
* @return array
|
||||
* Return all the rules to apply to this request's data.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'recaptcha:enabled' => 'required|in:true,false',
|
||||
|
@ -36,10 +34,7 @@ class AdvancedSettingsFormRequest extends AdminFormRequest
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'recaptcha:enabled' => 'reCAPTCHA Enabled',
|
||||
|
|
|
@ -10,10 +10,7 @@ class BaseSettingsFormRequest extends AdminFormRequest
|
|||
{
|
||||
use AvailableLanguages;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'app:name' => 'required|string|max:191',
|
||||
|
@ -22,10 +19,7 @@ class BaseSettingsFormRequest extends AdminFormRequest
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'app:name' => 'Company Name',
|
||||
|
|
|
@ -9,10 +9,8 @@ class MailSettingsFormRequest extends AdminFormRequest
|
|||
{
|
||||
/**
|
||||
* Return rules to validate mail settings POST data against.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'mail:host' => 'required|string',
|
||||
|
@ -28,12 +26,8 @@ class MailSettingsFormRequest extends AdminFormRequest
|
|||
/**
|
||||
* Override the default normalization function for this type of request
|
||||
* as we need to accept empty values on the keys.
|
||||
*
|
||||
* @param array $only
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function normalize(array $only = null)
|
||||
public function normalize(array $only = null): array
|
||||
{
|
||||
$keys = array_flip(array_keys($this->rules()));
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class UserFormRequest extends AdminFormRequest
|
|||
* Rules to apply to requests for updating or creating a user
|
||||
* in the Admin CP.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return Collection::make(
|
||||
User::getRulesForUpdate($this->route()->parameter('user'))
|
||||
|
|
Reference in a new issue