2017-06-11 03:28:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Admin;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
|
|
|
|
class UserFormRequest extends AdminFormRequest
|
|
|
|
{
|
|
|
|
/**
|
2018-01-01 18:13:08 +00:00
|
|
|
* Rules to apply to requests for updating or creating a user
|
|
|
|
* in the Admin CP.
|
2017-06-11 03:28:44 +00:00
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
2018-01-01 18:13:08 +00:00
|
|
|
$rules = collect(User::getCreateRules());
|
2017-06-11 03:28:44 +00:00
|
|
|
if ($this->method() === 'PATCH') {
|
2018-01-01 18:13:08 +00:00
|
|
|
$rules = collect(User::getUpdateRulesForId($this->route()->parameter('user')->id))->merge([
|
|
|
|
'ignore_connection_error' => ['sometimes', 'nullable', 'boolean'],
|
2017-12-03 20:00:47 +00:00
|
|
|
]);
|
2017-06-11 03:28:44 +00:00
|
|
|
}
|
|
|
|
|
2018-01-01 18:13:08 +00:00
|
|
|
return $rules->only([
|
|
|
|
'email', 'username', 'name_first', 'name_last', 'password',
|
|
|
|
'language', 'ignore_connection_error', 'root_admin',
|
|
|
|
])->toArray();
|
2017-06-11 03:28:44 +00:00
|
|
|
}
|
|
|
|
}
|