Implement a better management interface for Settings (#809)
This commit is contained in:
parent
75eb506dab
commit
f9df463d32
40 changed files with 1274 additions and 383 deletions
44
app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php
Normal file
44
app/Http/Requests/Admin/Settings/MailSettingsFormRequest.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Settings;
|
||||
|
||||
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||
|
||||
class MailSettingsFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Return rules to validate mail settings POST data aganist.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'mail:host' => 'required|string',
|
||||
'mail:port' => 'required|integer|between:1,65535',
|
||||
'mail:encryption' => 'present|string|in:"",tls,ssl',
|
||||
'mail:username' => 'string|max:255',
|
||||
'mail:password' => 'string|max:255',
|
||||
'mail:from:address' => 'required|string|email',
|
||||
'mail:from:name' => 'string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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($only = [])
|
||||
{
|
||||
$keys = array_flip(array_keys($this->rules()));
|
||||
|
||||
if (empty($this->input('mail:password'))) {
|
||||
unset($keys['mail:password']);
|
||||
}
|
||||
|
||||
return $this->only(array_flip($keys));
|
||||
}
|
||||
}
|
Reference in a new issue